Skip to content

fix: repair sync-pre-commit and harden the bot's version step - #293

Merged
robcohen merged 2 commits into
mainfrom
fix/sync-pre-commit
Aug 21, 2026
Merged

robcohen merged 2 commits into
mainfrom
fix/sync-pre-commit

Conversation

@robcohen

Copy link
Copy Markdown
Member

Two independent silent failures found while reviewing #284 / #287 / #289. Same family as those: something that looks like it worked, didn't.

1. sync-pre-commit couldn't parse bun.lock, and hid it

JSON.parse rejected the lockfile with "Property name must be a string literal" — bun writes JSONC with trailing commas (first one after web-tree-sitter, line 34). Bun.file().json() is equally strict, so there was no drop-in.

The script then swallowed it: main().catch() logged the error and left the exit code at 0. So just sync-pre-commit and the package script both reported success while doing nothing.

Fixed by stripping trailing commas before parsing — skipping string literals, so a comma inside a package name or version range can't be mistaken for a structural one — and setting process.exitCode = 1 in the catch.

Verified:

case before after
real bun.lock threw, exit 0 parses 385 package entries, exit 0
corrupted lockfile exit 0 exit 1

Worth knowing: the script has nothing to rewrite today regardless. It looks for "name@version" strings and .pre-commit-config.yaml no longer contains any — the biome hook pins a rev:, and the sole additional_dependencies entry is unversioned. That format did exist historically (it's still invoked from justfile:253). Someone should decide whether the script is still wanted; this at least makes it say so when it breaks.

2. The bot's "Get version" step interpolated a dispatch payload into bash

VERSION="${{ github.event.client_payload.version }}"

${{ }} is pasted into the script text before bash parses it — the standard script-injection shape, and the same class as the PR-body bug fixed in #289. Here the value arrives from a repository_dispatch payload. Moved to env:.

Also in this step: quotes $GITHUB_OUTPUT (the SC2086 actionlint has been reporting on this workflow — I'd left it alone in #287 as out of scope), adds set -euo pipefail, and fails loudly when neither input supplies a version instead of continuing with an empty one. Reads use ${VAR:-} because only one of the two is populated for any given event, and set -u would otherwise abort on the unused one.

actionlint on this workflow now exits 0, from one finding before — checked via exit code, not grepped output.

Simulated all three paths:

workflow_dispatch    -> version=v0.23.0   exit 0
repository_dispatch  -> version=v0.24.0   exit 0
neither supplied     -> "no rustledger version supplied", exit 1

Risk

tsc and eslint pass on the changed script. The workflow change affects only how the version is read; no change to what the bot commits.

robcohen and others added 2 commits August 21, 2026 20:04
Two independent silent failures found while reviewing #284/#287/#289.

1. sync-pre-commit could not parse bun.lock, and hid it.

`JSON.parse` rejected the lockfile with "Property name must be a string
literal": bun writes JSONC with trailing commas (the first is after
"web-tree-sitter" on line 34). `Bun.file().json()` is equally strict, so
there was no drop-in.

The script then swallowed the failure — `main().catch()` logged the
error and left the exit code at 0 — so `just sync-pre-commit` and the
`sync-pre-commit` package script both reported success while doing
nothing at all.

Fixed by stripping trailing commas before parsing, skipping string
literals so a comma inside a package name or version range can never be
mistaken for a structural one, and by setting `process.exitCode = 1` in
the catch. Verified: the lockfile now parses to 385 package entries
(previously it threw), a deliberately corrupted lockfile exits 1, and
the restored one exits 0.

Worth knowing: the script has nothing to rewrite today regardless. It
looks for `"name@version"` strings, and .pre-commit-config.yaml no
longer contains any — the biome hook pins a `rev:` and the only
additional_dependencies entry is unversioned. The format it targets did
exist historically. Someone should decide whether the script is still
wanted; this change at least means it will say so when it breaks.

2. The bot's "Get version" step interpolated a dispatch payload into bash.

`${{ github.event.client_payload.version }}` was pasted into the script
text before bash parsed it, which is the standard script-injection shape
— the same class as the PR-body bug fixed in #289, and here the value
arrives from a repository_dispatch payload. Moved to `env:`.

Also quotes $GITHUB_OUTPUT (the SC2086 actionlint has been reporting on
this workflow), adds `set -euo pipefail`, and fails loudly when neither
input supplies a version instead of continuing with an empty one. Reads
use `${VAR:-}` because only one of the two is populated for any given
event and `set -u` would otherwise abort on the unused one.

actionlint on this workflow now exits 0, from one finding before.
Simulated all three paths: workflow_dispatch and repository_dispatch
each resolve their version and write it to $GITHUB_OUTPUT, and the
neither-supplied case exits 1 with a message.
@robcohen
robcohen merged commit ba476de into main Aug 21, 2026
32 checks passed
@robcohen
robcohen deleted the fix/sync-pre-commit branch August 21, 2026 20:45
robcohen added a commit that referenced this pull request Aug 22, 2026
* ci: publish multi-arch (amd64/arm64) Docker images

The Dockerfile hardcoded an x86_64 wasmtime CLI download, so the
published image only ran on amd64 (arm64 hosts like Apple Silicon had
to emulate or build from source, and the build failed there anyway).

Dockerfile:
- Drop the wasmtime CLI download entirely: the runtime uses wasmtime-py
  (a core dependency with prebuilt wheels for both arches) since the
  JSON-RPC engine was replaced by the component engine.
- Build the frontend in a separate stage pinned to $BUILDPLATFORM: bun
  is unreliable under QEMU user emulation, and the JS/CSS output is
  architecture-independent, so cross-builds never run it emulated. The
  build backend then skips its bun step because the prebuilt static
  assets are fresher than the frontend sources.
- Pre-fetch the (arch-independent) rustledger component wasm into the
  image so containers work offline and the first request does not
  stall on a download.
- Bind dual-stack ([::]) by default: Docker publishes ports on IPv6
  too, and browsers resolve localhost to ::1 first, so an IPv4-only
  bind made http://localhost:<port> fail on many hosts.

publish.yml docker job:
- Build and push linux/amd64 + linux/arm64 via buildx/QEMU on tags.
- Run the build + smoke (no push) on PRs and main too, so multi-arch
  regressions surface before a release.
- Fix the (previously never-executed) smoke step: keep the container
  for docker logs, avoid the grep -q SIGPIPE/pipefail flake, and
  assert on rendered ledger data + a query API round trip instead of
  the string "rustfava" (the page only contains it by accident when
  the ledger's file path does).

Co-Authored-By: Claude Fable 5 <[email protected]>

* ci: quote $GITHUB_OUTPUT in the docker version step

Small fixup on top of the multi-arch work, kept as its own commit so the
authored change stays untouched.

The new "Extract version" step wrote to $GITHUB_OUTPUT unquoted twice,
which shellcheck flags as SC2086. Same pattern as the one fixed in #293.

This also clears a pre-existing finding: the step it replaces
("Extract version from tag") had the same unquoted write, so actionlint
on publish.yml goes from 4 findings on main to 3 here.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr

---------

Co-authored-by: Quanuanc <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
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