Skip to content

github-backup(app_setup): config, bws output and the conversion response are parsed unguarded — a wrong-shape config crashes every subcommand at import, and convert stores a partial credential set before crashing on a missing field #6849

Closed

Description

@dezren39

github-backup(app_setup): the App lifecycle helper parses config, bws output and the conversion response unguarded — a wrong-shape config crashes every subcommand at import, wrong-shape bws output raises raw Attribute/Key/JSONDecode errors, and convert stores a partial credential set before crashing on a missing field

Evidence (verified this run, laptop primary @ 65beb42)

infra/github-backup/bin/app_setup.py is the lifecycle helper for the
developing-today-backup GitHub App (manifest / convert / install-report /
webhook-secret). Every value it reads crosses a trust boundary with no
shape check:

  1. Config is indexed at import time. ghb_common.load_config()
    (infra/github-backup/bin/ghb_common.py:17-19) is a bare json.load
    with no validation — plan/state got validate_plan/validate_state
    (github-backup(fetch): a valid-JSON but wrong-shape plan/state entry crashes the whole daily fetch — one poison entry in plan.json or state.json wedges every repo, every day #6637), config never got an equivalent. app_setup.py:34-35 then runs
    CFG = load_config() and NAMES = CFG["app"]["bitwarden_secret_names"]
    at module top level, so a wrong-shape config.json kills every
    subcommand — including manifest, which needs only two fields — before
    main runs. app_manifest direct-indexes further fields at :40, :43,
    :48 (app.name, worker.webhook_path, app.events).
  2. bws output is parsed unguarded, and two of the three readers never
    check the return code.
    _bws_list (:52-58) checks returncode but
    returns json.loads(...) unchecked; its callers scan it with
    s.get("key") (:75, :95). _project_id (:61-70) never checks the
    return code and ends at projects[0]["id"]. bws_get (:94-104) never
    checks the return code and ends at json.loads(r.stdout)["value"].
  3. convert stores credentials one at a time from an unvalidated
    response.
    cmd_convert (:127-144) direct-indexes the
    /app-manifests/<code>/conversions response and calls bws_set four
    times in sequence (:138-141). A response missing a late field crashes
    after the earlier secrets are already stored, leaving a partial,
    inconsistent credential set in Bitwarden (new app id / client id /
    client secret, stale or absent private key).
  4. Same pattern in install-report: the installations response is
    iterated with i["account"]["login"] / i["id"] unguarded (:180+).

Probe (laptop, ~/git/fleet/probe-app-setup-shape/, real files verbatim, stubbed transport/bws)

Control (real config.json): import OK, NAMES populated.

Case Result
config missing app KeyError: 'app' at import
config app is a list / top level is a list TypeError: list indices must be integers... at import
bitwarden_secret_names is a string import passes with NAMES: str; first NAMES["app_id"] raises TypeError: string indices...
bws secret list returns an error-object dict AttributeError: 'str' object has no attribute 'get'
bws secret list returns [1, 2] AttributeError: 'int' object has no attribute 'get'
bws project list returns a dict KeyError: 0
bws project list exits 1, empty stdout misleading RuntimeError: no Bitwarden projects visible to this token — the actual bws failure is invisible (no return-code check)
bws secret get exits 1, empty stdout raw JSONDecodeError (no return-code check)
conversion response missing pem KeyError: 'pem' after 3 of 4 secrets already stored (app_id, client_id, client_secret)

Why it matters

This helper runs at the most sensitive moment of the backup system: App
creation and credential rotation for the App the whole mirror estate
depends on. A malformed local config edit (the config file's own header
says adding an owner is "an edit to this file") currently produces a raw
traceback with no field named; a bws hiccup is misreported as "no
projects visible"; and a short conversion response silently leaves
Bitwarden holding half of a new credential set, so the next run mixes
credentials from two different Apps.

Acceptance criteria

  • load_config (or an app_setup-local equivalent) validates the config
    shape the github-backup tools actually use — at minimum the app
    section (name, events, bitwarden_secret_names as a string->string
    object) and worker.webhook_path — and a violation is a clean,
    field-naming diagnostic, never a raw KeyError/TypeError traceback,
    for every subcommand.
  • _bws_list, _project_id, and bws_get check the subprocess return
    code and the parsed shape (list of objects with the fields they read);
    a bws failure reports the bws failure (stderr excerpt), not a shape
    accident or a false "no projects" claim.
  • cmd_convert validates the full conversion response (all of id,
    client_id, client_secret, pem, slug present and correctly
    typed) before the first bws_set, so a bad response stores
    nothing.
  • install-report validates the installations payload shape before
    indexing account.login/id.
  • Tests in infra/github-backup/tests/ cover the probe cases above
    (wrong-shape config, wrong-shape bws output, failed bws calls,
    partial conversion response storing nothing); the real-config control
    still passes.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    on Nov 7, 2026
  2. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (lane A, new-issue-creator-code-a)
    • Session / ID: cron new-issue-creator-code-a, run 2026-11-07 01:35 CST
    • Found via: filed this run
    • Task: Validate config/bws/conversion/installations shapes in app_setup.py (and load_config) so wrong-shape inputs produce field-naming diagnostics, bws failures report as bws failures, and convert validates the full response before storing any credential.
    • Expectation: effort s — done when the acceptance criteria on this issue pass with new tests in infra/github-backup/tests/ and the real-config control still passes.
    • Links: probe ~/git/fleet/probe-app-setup-shape (laptop); body file hidden_files/creator-a-2026-11-07-0135/issue-app-setup-shape.md
  4. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 8, 2026
  5. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · handed off

  6. 47 remaining items

  7. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off to opencode claimant — Agent: queue worker (repo-worker-code), lane code-b — Session/ID: task 11070, repo-queue-worker-shift-b 2026-11-09 run. Task 11070 (small_fix) for issue #6849: app_setup config/bws/conversion shape validation; attempts 4/4 (at cap). Fresh check: issue #6849 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels, no status/needs-triage. Execution lane row 3544 = opencode. Handoff reason: scheduled shift is time-bounded; claimant is the persistent execution session. Checkpointed handed_off; parking task 11070 for 20 minutes for the claimant window.

  8. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  9. added
    priority/lowNice to have; do when convenient
    and removed
    priority/normalOrdinary priority (the default)
    on Nov 11, 2026
  10. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · app_setup shape validation shipped as PR #8689 — parked on review (task 11070, lane code-c)

  11. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Correction to the note above: the PR is #8690 (the note's "#8689" was a pre-creation guess). All other details stand. Resume: Codex verdict on PR #8690 head b1c5db7 clean -> merge -> complete task 11070 fixed_merged, close #6849.

  12. added a commit that references this issue on Nov 11, 2026
  13. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — PR #8690 merged (task 11070, lane code-c)

  14. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 11, 2026
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

    app/github-backupinfra/github-backup estate mirror systemkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions