Fix #6029 Avoid undefined checksums after merge conflict resolution #6704
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's the problem this PR addresses?
Resolves #6029
Running
yarn --mode=update-lockfile
during git conflict resolution, performsautofixMergeConflicts
. If theyarn.lock
file has entries that lack achecksum
value, that process introduces anundefined
checksum value which is likely to be committed by accident. Subsequent full installs will remove them, but they're a cause of friction during their temporary existence.In my case under Yarn
4.5.3
usingnodeLinker: node-modules
it was injectingchecksum: 10/undefined
, while in #6029 it was injectingchecksum: undefined
. I note the__metadata.cacheKey
prefix (10/
in my case) can vary from project to project....
How did you fix it?
Explicitly checking for
undefined
in theautofixMergeConflicts
method.I struggled to figure out a way to add test coverage for this. I tried to add an extra dependency into the
it should properly fix merge conflicts
test case withinpackages/acceptance-tests/pkg-tests-specs/sources/features/mergeConflictResolution.test.ts
, however it always injects a checksum value, so i'm not sure how to emulate a missing one? Open to guidance there.In my project's
yarn.lock
most entries do have a checksum, while some do not, as a mixture ofnpm:
andworkspace:
protocol entries, so i'm not sure what the rules are for when the checksum is added?Manual QA
I tested this by updating my project's
.yarnrc.yaml
yarnPath
to point toscripts/run-yarn.js
from my localyarn-berry
checkout. Then in my external project i replicated a git conflict within ayarn.lock
entry, and usedyarn --mode=update-lockfile
to validate my fix correctly avoided introducingchecksum: 10/undefined
for entries lacking a checksum value....
Checklist
If i've selected the wrong packages please let me know. Given this PR touches a commonly used package i opted for a partial release rather than all dependents. Happy to change based on reviewer feedback.