Skip to content

fix(builder): Fall back to NpmSpec for node engine version ranges - #582

Merged
balamurali27 merged 1 commit into
developfrom
fix/npm-engine-version-spec
Aug 18, 2026
Merged

fix(builder): Fall back to NpmSpec for node engine version ranges#582
balamurali27 merged 1 commit into
developfrom
fix/npm-engine-version-spec

Conversation

@balamurali27

Copy link
Copy Markdown
Contributor

Problem

ValidationManager.check_version parses every version constraint with semantic_version.SimpleSpec. That works for pyproject.toml's requires-python, but package.json's engines.node uses npm range syntax that SimpleSpec rejects outright:

spec SimpleSpec
>=18 <21 ValueError
18.x ValueError
20 || 22 ValueError

The ValueError escapes _validate_node_version, so the deploy fails with an unhandled exception instead of either passing validation or raising ContextValidationError.

Fix

Try SimpleSpec first (so requires-python's comma syntax keeps working), fall back to NpmSpec.

Testing

New agent/tests/test_builder.py covers 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 NpmSpec also rejects still raise out of check_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

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>
@mergify

mergify Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

The fallback is narrowly applied after SimpleSpec rejects a range, and no actionable regression was established.

Reviews (1): Last reviewed commit: "fix(builder): Fall back to NpmSpec for n..." | Re-trigger Greptile

@balamurali27
balamurali27 merged commit 3d66e0c into develop Aug 18, 2026
5 of 6 checks passed
@balamurali27
balamurali27 deleted the fix/npm-engine-version-spec branch August 18, 2026 10:06
balamurali27 added a commit that referenced this pull request Aug 18, 2026
fix(builder): Fall back to NpmSpec for node engine version ranges (backport #582)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant