Repository navigation
fix(ci): stop the bot silently discarding its own _WIT_VERSION bump - #287
Merged
Merged
Conversation
The gate step edits component_engine.py when the component's WIT package
version changes:
sed -i "s/_WIT_VERSION = \"${CUR_WIT}\"/.../" \
src/rustfava/rustledger/component_engine.py
but create-pull-request's add-paths allowlist named only engine.py, so
that edit was dropped. The PR body meanwhile reports "Bumped
`_WIT_VERSION` to <new> (if it changed)", so the change looks applied.
The result was a constant pinned at 3.4.0 against a component exporting
rustledger:ledger/*@3.11.0, unnoticed across several releases because
wasmtime matches component imports on semver compatibility — a host at
3.4.0 satisfies an import of 3.11.0, both being major 3. It would first
fail at a major WIT bump, which is exactly when the bot's pre-applied
fix would have been dropped again. Fixed by hand in #284.
The allowlist itself is right: it exists because create-pull-request
otherwise committed the workflow's working files, adding ~6 MB of sdist
weight per release (#243). The failure mode is that narrowing to an
allowlist makes every later edit opt-in, and omission is silent. Audited
the whole workflow: it edits exactly two files under src/ (engine.py at
line 125, component_engine.py at line 100) and both are now listed.
Added a comment saying so, since the next step to edit a new file will
hit this again.
No behaviour change until the next upgrade run.
This was referenced Aug 21, 2026
robcohen
added a commit
that referenced
this pull request
Aug 21, 2026
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.
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.
The bug
When the component's WIT package version changes, the gate step in
update-rustledger.ymlpre-applies the mechanical part of the upgrade for the human reviewer (line 100):sed -i "s/_WIT_VERSION = \"${CUR_WIT}\"/_WIT_VERSION = \"${NEW_WIT}\"/" \ src/rustfava/rustledger/component_engine.pybut
create-pull-requestwas scoped to an allowlist naming onlyengine.py:component_engine.pyisn't listed, so the edit is discarded. The PR body still announces it:so the change reads as applied, and the reviewer's checklist item looks pre-satisfied.
Why it went unnoticed
The constant sat at
3.4.0against a component exportingrustledger:ledger/*@3.11.0and nothing failed, because wasmtime matches component imports on semver compatibility — a host defined at 3.4.0 satisfies an import of 3.11.0, both being major 3. Verified by substitution:_WIT_VERSION3.11.03.4.0(what shipped)4.0.0a matching implementation was not found2.0.0So the drift is silent until a major WIT bump — which is precisely the moment the bot's pre-applied fix would be dropped again. Fixed by hand in #284.
The fix
Add
component_engine.pyto the allowlist.The allowlist itself is correct and worth keeping: it exists because
create-pull-requestotherwise committed the workflow's working files (component.wasm,.sha256,pr-body.md), adding ~6 MB of unconsumed sdist weight per release that also went stale on manual bumps (#243). The failure mode is inherent to narrowing — every later edit becomes opt-in, and omission is silent rather than loud.So I audited the whole workflow rather than just patching the one case. It performs exactly two in-place edits under
src/:src/rustfava/rustledger/component_engine.pysrc/rustfava/rustledger/engine.py(via$FILE)Both are now listed, and there are no other writes under
src/. Added a comment recording that every step-edited file must be listed, since the next step to touch a new file will hit this again.Risk
No behaviour change until the next upgrade run. YAML validated.
Not fixed here
Two further defects in the same workflow, reported in #284 and deliberately left out to keep this reviewable:
${{ steps.gate.outputs.reasons }}is interpolated into an unquoted heredoc (line 136), so backticks in the reason string are executed as command substitution — which is why the current chore: upgrade rustledger to v0.22.0 #284 body reads "WIT package version changed: -> (host bindings in likely need changes)" with both versions and the filename blanked. Fix is<<'EOF'plus injection throughenv:, which also closes the shell-injection surface.src/rustfava/rustledger/*.wasmis gitignored and the component is downloaded at runtime (see Component wasm cache is version-agnostic, so a rustledger version bump silently tests against the old component #286).Happy to fold either in if preferred.