Repository navigation
Description
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:
- Config is indexed at import time.
ghb_common.load_config()
(infra/github-backup/bin/ghb_common.py:17-19) is a barejson.load
with no validation — plan/state gotvalidate_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-35then runs
CFG = load_config()andNAMES = CFG["app"]["bitwarden_secret_names"]
at module top level, so a wrong-shapeconfig.jsonkills every
subcommand — includingmanifest, which needs only two fields — before
mainruns.app_manifestdirect-indexes further fields at :40, :43,
:48 (app.name,worker.webhook_path,app.events). - bws output is parsed unguarded, and two of the three readers never
check the return code._bws_list(:52-58) checksreturncodebut
returnsjson.loads(...)unchecked; its callers scan it with
s.get("key")(:75, :95)._project_id(:61-70) never checks the
return code and ends atprojects[0]["id"].bws_get(:94-104) never
checks the return code and ends atjson.loads(r.stdout)["value"]. convertstores credentials one at a time from an unvalidated
response.cmd_convert(:127-144) direct-indexes the
/app-manifests/<code>/conversionsresponse and callsbws_setfour
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).- Same pattern in
install-report: the installations response is
iterated withi["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 theapp
section (name,events,bitwarden_secret_namesas a string->string
object) andworker.webhook_path— and a violation is a clean,
field-naming diagnostic, never a rawKeyError/TypeErrortraceback,
for every subcommand._bws_list,_project_id, andbws_getcheck 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_convertvalidates the full conversion response (all ofid,
client_id,client_secret,pem,slugpresent and correctly
typed) before the firstbws_set, so a bad response stores
nothing.install-reportvalidates the installations payload shape before
indexingaccount.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
developing-today commentedon Nov 7, 2026
CODE-2117
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
developing-today commentedon Nov 8, 2026
🤖 Agent note · handed off
47 remaining items
dezren39 commentedon Nov 10, 2026
🤖 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.
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 11, 2026
🤖 Agent note · app_setup shape validation shipped as PR #8689 — parked on review (task 11070, lane code-c)
dezren39 commentedon Nov 11, 2026
🤖 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.
Merge pull request #8690 from developing-today/queue/11070-6849-app-s…
dezren39 commentedon Nov 11, 2026
🤖 Agent note · done — PR #8690 merged (task 11070, lane code-c)