Skip to content

Let the release parse a multi-stage Dockerfile - #39

Merged
jimhoyd merged 1 commit into
mainfrom
claude/tender-gates-13ovkk
Sep 17, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/tender-gates-13ovkk

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Problem and change

The v0.3.0 release failed in ten seconds with no output at all — not even docker's.

The step that proves the build image is pinned by digest reads the first line of the Dockerfile:

read -r instruction image < Dockerfile
[[ "$instruction" == FROM && "$image" =~ ^node:[a-zA-Z0-9._-]+@sha256:[a-f0-9]{64}$ ]]

read with two variables gives the second one the rest of the line. Since the TypeScript conversion made the Dockerfile multi-stage, the value actually tested was:

node:26-bookworm-slim@sha256:cd9f68… AS build

which a $-anchored pattern can never match. set -e then exits 1 silently — which is exactly why the failure named nothing and looked like an infrastructure problem.

The read now takes the stage alias as its own words and validates it: either there is no alias, or it is exactly AS followed by one name.

read -r instruction image stage alias extra < Dockerfile
[[ "$instruction" == FROM && "$image" =~ ^node:[a-zA-Z0-9._-]+@sha256:[a-f0-9]{64}$ ]]
[[ -z "$stage" || ( "$stage" == AS && -n "$alias" && -z "$extra" ) ]]

Absorbing the remainder into a throwaway variable would have fixed the symptom by weakening the check that a release build is digest-pinned. The point of the guard is supply-chain integrity, so it validates what it now skips over.

Why this reached a tag at all. The guard exists only in the release workflow, which nothing but a tag push runs. npm run verify had no opinion about it, so a Dockerfile change and its guard could drift apart invisibly. A test now applies the same parse in CI, and asserts the workflow still splits the line the same way — so the two can't diverge again.

Verification

npm run verify   # 276 tests, 0 fail, 29 skipped

I confirmed the fixed guard accepts the real Dockerfile by running the exact shell:

image=[node:26-bookworm-slim@sha256:cd9f68…] stage=[AS] alias=[build] extra=[]
GUARD PASSES

And that the new test catches both ways this can break:

# malformed alias in the Dockerfile
not ok - the release can parse the Dockerfile it pins the build to
  error: 'unparsable stage alias on the FROM line: "FROM node:26-…@sha256:… AS build extra-token"'

# workflow reverted to the two-variable read
not ok - the release can parse the Dockerfile it pins the build to
  error: 'the release workflow reads the FROM line with a different word split'

Every run: block still passes bash -n.

Not verified: as always, the release workflow only runs on a tag push. This is the fourth distinct failure on the path to a first publish, and each one was only observable from a tag — which is the underlying problem, not any individual bug.

Compatibility and security

  • Workflow and one test. No runtime, API, YAML or CLI change.

  • The digest pin is not relaxed: the image must still be node:<tag>@sha256:<64 hex>, and the stage alias is now checked rather than ignored.

  • No change to provenance, signing, publishing order or the PUBLISH_NPM/NPM_TOKEN guard.

  • Changes match the documented portable contract; docs/examples are updated where needed.

  • Relevant tests and package checks pass, or limitations are explained above.

  • No credentials, customer data or private project material are included.

  • Runtime/starter changes remain aligned where applicable.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WrwFcAcntyBBSk21irvgAV


Generated by Claude Code

The v0.3.0 release failed in ten seconds with no output. The step that
proves the build image is pinned by digest reads the first line:

  read -r instruction image < Dockerfile
  [[ "$instruction" == FROM && "$image" =~ ^node:...@sha256:[a-f0-9]{64}$ ]]

With two variables the second takes the rest of the line, so since the
TypeScript conversion made the Dockerfile multi-stage the value tested
was

  node:26-bookworm-slim@sha256:cd9f68... AS build

which the anchored pattern can never match. set -e then exits 1 without
printing anything, which is why the failure named nothing.

The read now takes the stage alias as its own words and validates it:
either there is no alias, or it is exactly AS followed by one name.
Absorbing the remainder silently would have fixed the symptom by
weakening the check that a release build is pinned.

This was invisible until a tag push because the guard lives only in the
release workflow, which nothing else runs. A test now applies the same
parse to the Dockerfile in npm run verify, and asserts the workflow
still splits the line the same way, so the two cannot drift. Both
failure modes are covered: a malformed alias fails the first assertion,
and reverting the workflow's read fails the second.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WrwFcAcntyBBSk21irvgAV
@jimhoyd
jimhoyd merged commit 1a00294 into main Sep 17, 2026
26 checks passed
@jimhoyd
jimhoyd deleted the claude/tender-gates-13ovkk branch September 17, 2026 17:32
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.

2 participants