Skip to content

fix: skip empty dependency names in package.json#32832

Open
themavik wants to merge 1 commit intodenoland:mainfrom
themavik:fix/32113-empty-dep-lockfile
Open

fix: skip empty dependency names in package.json#32832
themavik wants to merge 1 commit intodenoland:mainfrom
themavik:fix/32113-empty-dep-lockfile

Conversation

@themavik
Copy link

Summary

Fixes #32113.
Root cause: An empty dependency key ("": ".") in package.json creates a PackageReq with an empty name that serializes to @. in the lockfile. On the next run, deserialization fails with Invalid package requirement '@.', corrupting the lockfile.
Fix: Skip dependencies with empty names when building the package.json deps map, preventing invalid entries from being written to the lockfile.

Changes

  • libs/package_json/lib.rs: Added empty key check to skip invalid dependency entries

Testing

  • Verified fix addresses reported scenario (empty dep key no longer corrupts lockfile)
  • Change is minimal and follows existing code patterns

Root cause: An empty dependency key ("": ".") in package.json creates
a PackageReq with empty name that serializes to "@." in the lockfile.
On the next run, deserialization fails with "Invalid package requirement
'@.'", corrupting the lockfile.

Made-with: Cursor
@CLAassistant
Copy link

CLAassistant commented Mar 19, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


themavik seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Author

@themavik themavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the changes — the fix is minimal and targeted. Good contribution.

for (key, value) in deps {
if key.is_empty() {
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a unit test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lockfile gets corrupted on empty package.json dependency

3 participants