Skip to content

Add proper support for ? operator#3

Merged
spanishpear merged 2 commits intospanishpear:mainfrom
nahuja2:bugfix/fix-issue-with-long-descriptor-lines
Oct 13, 2025
Merged

Add proper support for ? operator#3
spanishpear merged 2 commits intospanishpear:mainfrom
nahuja2:bugfix/fix-issue-with-long-descriptor-lines

Conversation

@nahuja2
Copy link
Copy Markdown
Contributor

@nahuja2 nahuja2 commented Oct 13, 2025

There seems to be some undocumented behaviour that Yarn engages in, where for very long descriptor lines in a lockfile, it will prefix them with a ? character and then place the : on a new line before the rest of the package info. For example:

? "@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.1.5, @babel/runtime@npm:^7.10.0, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.10.4, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.0, @babel/runtime@npm:^7.12.1, @babel/runtime@npm:^7.12.13, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.15.4, @babel/runtime@npm:^7.16.3, @babel/runtime@npm:^7.16.7, @babel/runtime@npm:^7.17.8, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.18.6, @babel/runtime@npm:^7.18.9, @babel/runtime@npm:^7.2.0, @babel/runtime@npm:^7.20.1, @babel/runtime@npm:^7.20.13, @babel/runtime@npm:^7.20.6, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.22.6, @babel/runtime@npm:^7.23.9, @babel/runtime@npm:^7.26.0, @babel/runtime@npm:^7.26.10, @babel/runtime@npm:^7.27.0, @babel/runtime@npm:^7.27.4, @babel/runtime@npm:^7.3.1, @babel/runtime@npm:^7.4.4, @babel/runtime@npm:^7.5.0, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.6.0, @babel/runtime@npm:^7.6.3, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.7.4, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.7.7, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2"
:
  version: 7.28.4
  resolution: "@babel/runtime@npm:7.28.4"
  checksum: 10/6c9a70452322ea80b3c9b2a412bcf60771819213a67576c8cec41e88a95bb7bf01fc983754cda35dc19603eef52df22203ccbf7777b9d6316932f9fb77c25163
  languageName: node
  linkType: hard

Right now, this isn't supported by this crate - these entries just get kind of skipped over and blended with the next entry in the lockfile. This is because nom tries to parse this with the

    alt((
      delimited(char('"'), take_until("\":"), tag("\":")), // Quoted: "package@npm:version":
      terminated(take_until(":"), char(':')), // Unquoted: package@latest:
    ))
    .parse(rest)?

parser, which partially succeeds but isn't expecting a newline before the :. This PR fixes this issue by checking for the ? indicator and using a different parser to correctly handle the situation.

Copy link
Copy Markdown
Owner

@spanishpear spanishpear left a comment

Choose a reason for hiding this comment

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

this seems sensible and well tested. Thanks!

@spanishpear spanishpear merged commit baad368 into spanishpear:main Oct 13, 2025
3 of 5 checks passed
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.

2 participants