Repository navigation
fix(platform): fail the image build when its production install fails - #4004
Conversation
The pruner's RUN chained the production install, the swap into
/app/node_modules and the optional cleanup into one sh AND-OR list.
sh groups && and || left to right, so the cleanup's first unbraced
`|| true` also caught a failed install: Bun 1.3.12 refused the
lockfile ("lockfile had changes, but lockfile is frozen"), the stage
still succeeded, and the image shipped the builder's full dev
node_modules (typescript, vitest, storybook, vite and the rest).
The refusal came from the manifests. Stage 1 installs from
tools/opengrep's manifest and writes its lockfile with that workspace,
but the pruner never copied it, so the frozen production install saw
one workspace fewer. The pruner now copies it, the cleanup keeps its
`|| true`s inside braces, and a guard runs the RUN's own text under
/bin/sh with recording doubles (a failed install or swap fails the
RUN, a failed cleanup does not) and pins the pruner's manifests to
stage 1's.
The same unbraced `|| true` also swallowed a failed package install
or SOPS download in the runner stage and a failed engine install in
the sandbox-runtime image; both are braced and guarded the same way.
|
Independent/root review accepts the five-file correction at All six normal workflows are terminal-success at this head. The actual hosted merge The normal shipping platform pruner actually executed Bun 1.3.12, installed 1,689 packages and completed without an install error; required platform-runner and sandbox engine stages also executed. The platform digest Limits remain explicit: workspace-deps was cached, shared UI browser results were replayed, scans completed/SARIF uploaded but their informational configuration is not a zero-vulnerability gate, and the existing unfrozen builder/prepare lifecycle is not a hermetic-install claim. The author's complete import-closure/package-delta claims are separate from this independently observed proof. Root also checked the two already accepted subsequent main commits; none touches this PR's five files. A fresh candidate/publication/deployment is still required. Final independent report SHA256: |
What changed
Root cause. The platform pruner stage ran
HUSKY=0 bun install --production && rm -rf /app/node_modules && mv … && rm -rf <dev tools> 2>/dev/null || true && find … || true …as one sh AND-OR list. sh groups&&and||left to right, so the first unbraced|| true(and every later one) also caught a failed install. The install fails because of the manifests. Stage 1 copiestools/opengrep/package.json(since 121733e, 2026-06-17), and its unfrozenbun installwrites a lockfile that includes that workspace. The pruner never copied that manifest, so--production, which freezes the lockfile, saw one workspace fewer and refused withlockfile had changes, but lockfile is frozen. The stage still passed. The swap and the explicit rm-list were skipped as well, so the runtime image shipped the builder's full devnode_modules(typescript, vitest, storybook, vite, rolldown, playwright-core, tsx, …).Fix. Same Dockerfiles and pipeline, smallest change:
services/platform/Dockerfile, pruner: copytools/opengrep/package.jsonas stage 1 does. Wrap only the optional cleanup in{ …; }, so its|| trues can no longer reach the install or the swap.Same defect, two more sites:
groupadd … || true/useradd … || truealso swallowed a failedapt-get installor SOPS download. Now braced.services/sandbox-runtime/Dockerfile, the trailingrm -f …docker.service 2>/dev/null || trueswallowed a failed docker-ce install. Now braced.services/db/Dockerfilerunsset -eux; cmd || true;one command at a time, and the|| echoinservices/web/Dockerfilesits in a RUN that holds only its best-effort command.New guard,
services/platform/tests/guards/dockerfile-fail-closed.guard.test.ts. It runs each of these RUNs' own text under/bin/sh, as BuildKit's shell form does, with recording doubles on a privatePATH:groupadd/useraddor unit strip must not;It reads
services/sandbox-runtime/Dockerfile, so that file is added to the platformtestturbo inputs and to the turbo-inputs guard's list.Unchanged: the image's Bun pin (1.3.12), frozen-lockfile validation (
--productionstill freezes the lockfile), workspace dependencies, the architecture matrix and the cleanup list itself.How I verified it
Toolchain.
bun 1.3.12+700fc117a, extracted fromoven/bun:1.3.12@sha256:8956c7667fa1…(the digest the hosted build resolved; binary sha2561ac6637e4894…).node v22.21.1, fromnode:22.21.1-bookworm-slim@sha256:25b3eb23a005….This sandbox has no Docker daemon, so I replayed the stages outside BuildKit. The replay parses stage 1's COPY list and the pruner's COPY list and RUN text from the Dockerfile at each revision. It then runs the RUN verbatim through
/bin/sh -c, with/appand/tmpremapped under a scratch root.error: lockfile had changes, but lockfile is frozen, RUN exit 0: the same output as hosted job 109868513524, step #731689 packages installed, RUN exit 0tools/opengrep, a manifest-only workspace; that is the whole divergenceRuntime contents.
name@versionremoved (2063 → 1607 entries, 1008 → 707 MB).backend/node-loader.mjswalks 957 first-party files and reaches 41 packages.server.tswalks 72 files and reaches 12 packages.honoreports 88 unresolved imports on the Node side and 4 on the Bun side.name@versionas today. The only exceptions are type-only@types/*packages, which the rm-list deletes by design.Tests and checks.
dockerfile-env-parity,turbo-inputs,privilege-dropand new guard files together pass 57/57.tools/clicompose-parity, deployment-ci and platform-docs suites pass 125/125.oxlint --type-awareon the changed files and a scoped tsc are clean. The workspace-wide gates are left to CI.Hosted proof from this PR's run. CI builds merge commit
5ec0d41b, whose treefc2d5c01…is identical to headfc54249a9.#79:bun install v1.3.12 (700fc117)→1689 packages installed [7.43s]→DONE, with noerror:. Image receipt:sha256:2bdc2d52eecb1b99499f2f3213c457573bf219a1d631f5faafe6ab27397f57cc↔5ec0d41b.Setting up docker-ce … DONE 15.6s).tale-platform:sha-4d14c55d5) has anode_modulesinventory identical to the local base replay: 2063 entries;typescript,vitest,storybook,playwright-core,tsxand@typesgone./app: 0 unresolved imports on the Node side (957 files) and on the Bun side (72 files).Open items
preparescript, which usesbunxto fetchhusky@latest: husky is not installed in production, andHUSKY=0makes the call a no-op. This is pre-existing and was hidden while the install failed. A follow-up could pin husky there or skip lifecycle scripts.bun installstays unfrozen by design. It installs 14 of the 23 workspaces and re-resolves the committed lock for that subset, dropping 9 workspaces and re-hoistingentities. The committed lock itself is checked by CI'sbun install --frozen-lockfileunder Bun 1.4.2.Closes #3996