Repository navigation
fix(pnpm migration): fix "lockfileVersion" number parsing
#23232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f94b288
fix lockfileVersion number parsing
dylan-conway f41952f
Apply suggestion from @dylan-conway
dylan-conway 2eb7194
[autofix.ci] apply automated fixes
autofix-ci[bot] 061c9f1
Add error message for old pnpm lockfile version
fa1fbac
Revert "Add error message for old pnpm lockfile version"
dylan-conway 34fc446
update
dylan-conway 55d0f78
update
dylan-conway File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
1 change: 1 addition & 0 deletions
1
test/cli/install/migration/pnpm/version-number-dot/pnpm-lock.yaml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify: Parsing only major version, not full decimal version.
The code finds the first dot and parses only up to that point:
str[0..end]whereend = indexOfChar(str, '.') orelse str.len.For a version string like
"5.4":endwould be 1 (index of the first dot)str[0..end]would be"5"5.0is parsed, not5.4This contradicts the PR description stating that versions like
5.4should be handled. If the intent is to parse the full version including the decimal component, the code should parse the entire string, not just up to the first dot.If this is intentional (only major version matters for the version check at line 132), please clarify. Otherwise, apply this diff:
.e_string => |version_str| { const str = version_str.slice(allocator); - - const end = strings.indexOfChar(str, '.') orelse str.len; - break :lockfile_version std.fmt.parseFloat(f64, str[0..end]) catch break :err; + break :lockfile_version std.fmt.parseFloat(f64, str) catch break :err; },Run this script to check if the test fixture uses a version with a decimal component:
🏁 Script executed:
Length of output: 20
Parse full version string for
lockfileVersionThe code slices at the first dot and only parses the major version, but the fixture uses
lockfileVersion: 5.4, so this yields5.0instead of5.4. Replace lines 121–122 with:This ensures decimal versions like
5.4are parsed correctly.📝 Committable suggestion
🤖 Prompt for AI Agents