Skip to content

fix(core): take a leading-dash Apify reference as the positional value (#3689) - #4027

Merged
schlessera merged 1 commit into
mainfrom
fix/3689-leading-dash-references
Nov 15, 2026
Merged

schlessera merged 1 commit into
mainfrom
fix/3689-leading-dash-references

Conversation

@schlessera

Copy link
Copy Markdown
Owner

Declared fix for red-main incident #4026. Closes #3689.

Cause

Apify consent references and run handles are 32 random bytes in base64url (reference, packages/common/src/apify/consent.ts:412; packages/common/src/apify/ledger.ts:390). About one in 4,096 of them starts with --, and brain apify passed its arguments straight to the shared parseArgs, which refused such a value as Unknown flag. Main run 43738678603 failed in packages/ui-server/tests/apify-front-doors.test.ts:184 (cli(["run", prepared.proposal])) with Unknown flag: --dqYdZ-o38E…. #4023, the first bad SHA, touches only Claude transcript archive restore and does not reach this code. The decision and its rationale are recorded on #4026.

Change

  • packages/core/src/cli/commands/apify.ts: before parsing, brain apify moves a 43-character reference that starts with -- behind a bare --, where the shared parser keeps it positional verbatim. No flag has that shape. Other arguments keep their order, and anything already after a separator is untouched. The general parser, reference shape and entropy, stored records, and the MCP and hosted-bridge doors are unchanged. Both new and existing stored dashed values now work in the documented direct form, and the separator form still works.
  • packages/ui-server/tests/apify-front-doors.test.ts: a deterministic test spies on node:crypto's randomBytes so that every 32-byte draw encodes to a distinct ---leading value. It asserts that the consent reference, the proposal and the ledger run handle all start with --, then drives inspect (direct and through --), prepare, run, status, results and abort through the CLI.
  • Patch changeset for @schlessera/brain.

Contract: the CLI input shapes in docs/integration-contract/cli.md are unchanged, and the documented positional form now holds for every value.

Proof

  • Failing first: with only the referencesAsPositional call reverted in apify.ts, bun run test packages/ui-server/tests/apify-front-doors.test.ts gives 14 pass and 1 fail. The new test fails with Unknown flag: --odysseus4AAAA… at parseArgs (packages/core/src/cli/io.ts:115), the same failure seen on main. With the change restored: 15 pass, 0 fail.
  • tsc --noEmit is clean.
  • bun run check:pr --base origin/main passed:
{"version":1,"kind":"brain-check-pr-receipt","head":"ac762543f8dff4e5c2dcea0e56088817115c68ab","base":"origin/main","mode":"focused","startedAt":"2026-11-15T17:33:18.399Z","finishedAt":"2026-11-15T17:34:23.198Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12865.474023},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":107.07278099999894},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":86.08370699999796},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":21.451927000001888},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":51702.845315000006}]}

🤖 Generated with Claude Code

#3689)

About one in 4,096 random base64url Apify consent references and run
handles starts with --, and brain apify read it as an unknown flag. That
intermittently failed apify-front-doors on main (incident #4026). The
apify command now moves a 43-character dashed reference behind a bare --
before the shared parser runs. Shape, entropy, stored values and the
general parser are unchanged.

Closes #3689
Refs #4026

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 15, 2026
@schlessera
schlessera marked this pull request as draft November 15, 2026 17:36
@schlessera
schlessera marked this pull request as ready for review November 15, 2026 17:36
@schlessera
schlessera marked this pull request as draft November 15, 2026 17:42
@schlessera
schlessera marked this pull request as ready for review November 15, 2026 17:42
@schlessera
schlessera merged commit 23d6af8 into main Nov 15, 2026
49 of 65 checks passed
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.

core: an Apify reference that starts with -- is parsed as an unknown CLI flag

1 participant