fix(npm): tolerate malformed scripts field in packuments - #36324
Merged
Conversation
Deno Individual Contributor License AgreementAll contributors have signed the CLA. Thank you! This is an automated message from CLA Assistant |
Some historical packuments contain a `scripts` field that is not a map (e.g. npm:jsox@1.1.121 has `"scripts":""`). `has_install_script` parsed it as a `BTreeMap` and propagated the error, which aborted the entire packument load with: invalid type: string "", expected a map at line 1 column 2 Treat a `scripts` field that doesn't deserialize into an object as having no lifecycle scripts instead of failing the load. Closes #36323
bartlomieju
force-pushed
the
fix/npm-malformed-scripts-36323
branch
from
July 27, 2026 08:38
4126f46 to
dab03e1
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Installing or inspecting some packages that historically shipped a malformed
package.jsonfails on 2.9.x. For exampledeno info npm:jsoxerrors with:The cause is in the slim-packument caching path. When building the cached
packument,
has_install_scriptdeserializes each version'sscriptsfieldinto a
BTreeMap<String, &RawValue>and propagates any error. The versionjsox@1.1.121has"scripts": ""(an empty string rather than an object),so the parse fails and the error bubbles all the way up, aborting the load of
the entire packument.
This treats a
scriptsfield that doesn't deserialize into an object ashaving no lifecycle scripts, matching how the rest of the registry parsing
already tolerates malformed historical fields, instead of failing the whole
load.
Verified that
deno info npm:jsoxnow succeeds against a clean cache, andadded a unit test covering non-object
scriptsvalues.Closes #36323