Repository navigation
fix(shims): build a valid image tag from engines ranges - #18
Merged
Merged
Conversation
An engines.node range such as "^20.19.0 || >=22.12.0" produced the tag "node:^20-alpine", and docker run failed with "invalid reference format". Take the first major number of the last range alternative, and let only digits into the tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
A project with
"engines": { "node": "^20.19.0 || >=22.12.0" }made every shim call fail:resolve_imageonly removed<>=!, so the tag becamenode:^20-alpine(ornode:^20-bookwormfor wrangler projects).Fix
Take the first major number of the last
||alternative. That alternative is the newest range, which matters for wrangler: it needs Node 22 or later. Only digits can reach the tag, so^,~,xand*no longer break it. A range with no number (*) keeps the default image.>=20.1.0node:20-alpinenode:20-alpine^20.19.0 || >=22.12.0node:^20-alpine(invalid)node:22-alpine~20.xnode:~20-alpine(invalid)node:20-alpine*node:*-alpine(invalid)Tests
I added these cases to the existing image-selection test. Locally on macOS, the same 4 tests fail with and without this change (3, 4, 8 and the node-shell corepack test), because macOS reports temp paths under
/private/tmp. CI runs on Linux.🤖 Generated with Claude Code