fix(builder): Fall back to NpmSpec for node engine version ranges (backport #582) - #583
Merged
Merged
Conversation
package.json engines.node uses npm range syntax that SimpleSpec cannot
parse: space-separated ranges (">=18 <21"), x-ranges ("18.x") and
alternations ("20 || 22") all raise ValueError, failing the deploy
instead of validating the version.
Try SimpleSpec first so requires-python keeps its comma syntax, then
fall back to NpmSpec.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from commit e0e3d3e)
Contributor
Author
|
Tick the box to add this pull request to the merge queue (same as
|
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.
Problem
ValidationManager.check_versionparses every version constraint withsemantic_version.SimpleSpec. That works forpyproject.toml'srequires-python, butpackage.json'sengines.nodeuses npm range syntax thatSimpleSpecrejects outright:SimpleSpec>=18 <21ValueError18.xValueError20 || 22ValueErrorThe
ValueErrorescapes_validate_node_version, so the deploy fails with an unhandled exception instead of either passing validation or raisingContextValidationError.Fix
Try
SimpleSpecfirst (sorequires-python's comma syntax keeps working), fall back toNpmSpec.Testing
New
agent/tests/test_builder.pycovers both syntaxes, positive and negative, for each range form. Verified no spec that parses under both parsers gets a different verdict from them, so the fallback does not change behaviour for anything that already worked.Known gap
Specs that
NpmSpecalso rejects still raise out ofcheck_version—>= 18(space after the operator) and>=v18(v-prefix) are both legal npm but fail here. Not a regression, they failed before this change too. Happy to fold a normalization step in if you'd rather close that off in the same PR.🤖 Generated with Claude Code
This is an automatic backport of pull request #582 done by Mergify.