Skip to content

fix(shims): build a valid image tag from engines ranges - #18

Merged
gpmayorga merged 1 commit into
mainfrom
fix/engines-range-image
Nov 28, 2026
Merged

gpmayorga merged 1 commit into
mainfrom
fix/engines-range-image

Conversation

@gpmayorga

Copy link
Copy Markdown
Owner

Problem

A project with "engines": { "node": "^20.19.0 || >=22.12.0" } made every shim call fail:

docker: invalid reference format

resolve_image only removed <>=!, so the tag became node:^20-alpine (or node:^20-bookworm for 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 ^, ~, x and * no longer break it. A range with no number (*) keeps the default image.

engines.node before after
>=20.1.0 node:20-alpine node:20-alpine
^20.19.0 || >=22.12.0 node:^20-alpine (invalid) node:22-alpine
~20.x node:~20-alpine (invalid) node:20-alpine
* node:*-alpine (invalid) default

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

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>
@gpmayorga
gpmayorga merged commit e9eac0b into main Nov 28, 2026
5 checks passed
@gpmayorga
gpmayorga deleted the fix/engines-range-image branch November 28, 2026 13:47
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.

1 participant