Skip to content

Preserve managed-job refusal codes through contextual CLI errors #5840

Open

Description

@brsbl

Summary

Some core command wrappers replace typed CLI errors with plain Error, so managed-job refusals lose their machine-readable error code. The write remains blocked. This is a P2 follow-up from the architecture panel of #5839, deliberately excluded from that safety fix.

Versions and environment

Source CLI at b1a3eadf7f20da98d76c227046a02704e864740d, Linux. Reproduced inside a real host-care job with all fetch calls stubbed; zero network calls occurred.

Steps to reproduce

Build @bb/cli with Turbo and save the intercepting fetch stub from #5838 as mock-fetch.mjs. Run:

env -u BB_CLI -u BB_PROJECT_ID -u BB_THREAD_ID -u BB_ENVIRONMENT_ID \
  BB_CLI_ERROR_LOG=0 HOST_CARE_JOB_ID=guard-repro \
  BB_SERVER_URL=http://127.0.0.1:38886 GUARD_PROBE_LOG="$PWD/requests.jsonl" \
  node --import "$PWD/mock-fetch.mjs" apps/cli/dist/index.js \
  thread archive thr-guard-fixture --json

Expected vs actual

Expected: nonzero exit with managed_job_default_server_write and zero writes.

Actual: nonzero exit and zero writes, but a generic error code:

{
  "ok": false,
  "error": {
    "code": "error",
    "message": "Failed to archive thread thr-guard-fixture: Managed job refused POST http://127.0.0.1:38886; set BB_SERVER_URL to your isolated server and verify its exact dataDir with bb status --json before writing."
  }
}

Evidence

What was ruled out

The transport guard still prevents the request. Unwrapped plugin config, SDK plugin enable, and both plugin CLI forms preserve the code. Duplicate search for prependErrorContext error code found no matching issue.

Suggested priority and effort

P2: preserve the typed refusal through contextual wrappers and add a built-CLI regression for a wrapped mutation. Done when its JSON code remains specific with nonzero exit and zero transmitted writes.

AGENT GENERATED

Activity

  1. added theissue type on Oct 20, 2026
  2. added
    cli
    partial-repro
    on Oct 20, 2026
  3. bb-slop-cop commented on Oct 20, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Low · Area: cli.
    • Report: PARTIALLY REPRODUCED, with high confidence in the metadata-loss root cause. Two clean trusted-main builds preserve an SDK refusal code for an unwrapped read but return error for wrapped archive; both exit 1.
    • Root cause: prependErrorContext replaces the typed error with plain Error, so the action handler loses its code. The report includes the failing built-CLI regression and both runs’ output.
    • Reproduction label: partial-repro.
    • No PR: the exact managed-job refusal/zero-transmitted-writes scenario cannot be verified on trusted origin/main; its prerequisite guard remains in open PR Guard managed jobs against default-server CLI writes #5839.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clipartial-repro

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions