Skip to content

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

Closed

Description

@schlessera

Context

Apify consent references are random base64url strings (reference, packages/common/src/apify/consent.ts:412), and ledger handles are made the same way (packages/common/src/apify/ledger.ts:390). base64url includes -, so roughly 1 in 4,096 references starts with --. The CLI's parseArgs (packages/core/src/cli/io.ts:99-139) treats any argument starting with -- as a flag. brain apify inspect <reference> then fails with Unknown flag: --<reference>, which breaks the documented direct positional form. The existing bare -- separator already offers an escape; do not describe these stored references as irrecoverable.

Observed in hosted CI: packages/ui-server/tests/apify-front-doors.test.ts, test "the CLI keeps consent across invocations and refuses a run nobody can approve", failed with Unknown flag: --xSJpZdWZ…. The failure is intermittent and unrelated to the PR it appeared on.

Scope

Make newly generated opaque references/handles safe in the documented direct positional forms while keeping existing stored values resolvable. The existing -- parser path is available for legacy values: put options before the separator, for example brain apify prepare --input '{}' --max-charge-usd 1 -- --odysseus. Do not invalidate ledger rows or consent records. Keep the implementation concrete in the existing reference/handle generators or Apify argument handling; do not broaden the general parser.

Out of scope

Changing reference entropy, consent semantics or the general flag parser for other commands.

Acceptance criteria

  • Every newly generated consent reference and ledger handle works directly in its documented Apify positional command. Deterministic tests force leading -/-- random encodings at both generators; include inspect/prepare and run/status/results/abort consumers as applicable.
  • Existing stored leading-dash references/handles still resolve through the existing separator form; ordinary stored values retain their current lookup semantics. No entropy reduction or record migration.
  • The deterministic test fails before the fix.

Verification

bun run test packages/ui-server/tests/apify-front-doors.test.ts and the common Apify tests; bun run check:pr --base origin/main.

Contract impact

If generated references change shape, check the Apify CLI contract component; otherwise none. Patch changeset.

Current bounded reproduction

Bun 1.4.4 on the inspected SHA: parseArgs(["inspect", "--odysseus"]) throws Unknown flag: --odysseus; parseArgs(["inspect", "--", "--odysseus"]) preserves that exact positional value. Calling the real apifyCommand.run with an inert service passed candidate: "--odysseus" to inspect and prepare (options placed before --). This proves parsing/adapter behavior, not a live consent-ledger run. The generators remain reference at packages/common/src/apify/consent.ts:412 and handle creation at packages/common/src/apify/ledger.ts:390.

Triage 2026-11-08 at main 8752570331ffebdbb9233196412781f6cd71f3d9: Confirmed the unescaped parser refusal and successful existing separator path through the real command adapter with an inert service. Clarified legacy compatibility and deterministic coverage; p2 is wanted, unscheduled work.

Activity

  1. added
    type: fixSomething is broken and must behave the way it is documented.
    area: corepackages/core: the brain CLI, indexer, hybrid search, config, taxonomy, skills.
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 8, 2026
  2. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Observed again on #4023's automatic main run 43738678603, squash 4035f977e0cc471a5fbe795f447237c15890d3dd, unit shard 3 job 132887184373.

    At 17:12:15 UTC, packages/ui-server/tests/apify-front-doors.test.ts:184 (the CLI keeps consent across invocations and refuses a run nobody can approve) reaches parseArgs in packages/core/src/cli/io.ts:115 and throws Unknown flag for a generated reference beginning with --. Source still uses randomBytes(32).toString("base64url") at packages/common/src/apify/consent.ts:412 and ledger.ts:390. The failure is the already-described leading-dash reference case; #4023 changes only Claude archive restore timestamps, their tests, a changeset and documentation, and none of these Apify files differ from its tested base. The complete selected candidate run 43736220100 passed before squash.

    The shard records 1688 pass / 8 skip / 1 fail in that worker. A sibling worker is then interrupted (exit 143); its visual-dictation config probe reports a null child exit during that cancellation. That secondary diagnostic is retained here without claiming a separate root cause.

    No failed job was rerun, no test or gate was changed, and no correction to this issue was attempted under #3790. This remains the existing unscheduled follow-up with no release milestone, under the run's maintainer ruling for intermittent failures.

  3. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    This failure is tracked by red-main incident #4026 (main red at 4035f977e0cc). Please add evidence there.

  4. self-assigned this
    on Nov 15, 2026
  5. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-663a9a83. Branch: fix/3689-leading-dash-references.

  6. added this to the 0.45.0 milestone on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: corepackages/core: the brain CLI, indexer, hybrid search, config, taxonomy, skills.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: fixSomething is broken and must behave the way it is documented.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions