Repository navigation
Description
Problem
pkgs/cold-store-reaper/cold_store.py carefully converts invalid JSON in
credentials.json / state.json into a ColdStoreError with repair guidance
(load_credentials at :440-446, load_state at :455-462; tests exist for the
corrupt-syntax case), but valid JSON of the wrong shape slips straight past
both loaders:
load_credentials(:433, :447) callscreds.get(key)on whatever
json.loadsreturned. A top-level list, string, number, bool ornull
raises a rawAttributeError, with none of the file-naming repair guidance
the corrupt-syntax path gives.- The same loader's missing-field check is truthiness-only, so a non-string
value passes it:{"client_id": 123, ...}and{"client_id": ["x"], ...}
are both returned as if they were usable credentials and flow on into the
token-request encoding downstream. load_state(:452-455) returns whateverjson.loadsreturned unchecked.
Every caller assumes a dict (ensure_folders:754,_folder_id:775,
_d1_endpoint:1466-1475 all callstate.get(...)), so a non-object
state.jsoncrashes the next operation with a rawAttributeErrorfar
from the cause.- Even a top-level object is not enough: a non-object
foldersfield crashes
downstream (folders = "abc"→ rawValueErrorfromdict(...)in
ensure_folders;folders = 123→ rawTypeErrorin_folder_id;
folders = ["root"]→ rawTypeError: list indices must be integers),
and a non-string folder id is silently accepted —{"folders": {"bundles": 123}}makes_folder_id("bundles")return the integer123,
which is then used as a Drive folder id.
These files are operator-managed local state under the cold-store home:
edited by hand when filling credentials from Bitwarden, and rebuilt by the
tool itself. A wrong-shape write (an editor slip, a different tool writing
[]/null, a partial restore) should produce the same diagnosed refusal
the corrupt-syntax case already produces — not a traceback, and never a
silently mistyped folder id used against Drive (this tool deletes/evicts;
acting on a wrong identifier is the dangerous direction).
Evidence (verified this run)
Laptop primary ~/git/code at origin/main 65beb42c1a70672bed159fe401c2cb1079aa516f.
Probe: ~/git/fleet/probe-cold-store-state/ (probe.py, probe2.py,
probe3.py) against the real cold_store.py copied verbatim from
origin/main (sha256 39a1ecb1a8ff10dedcb59538cc6d2691d7a264e3def2afcb41963240dea27f2d),
using a temporary home — no network, no real credentials.
Controls (all as expected):
- missing
state.json→{}; dict state → returned unchanged - dict credentials with string fields → returned unchanged
- syntactically corrupt credentials (
{"client_id":) →ColdStoreError
naming the file and the repair path
Failing shapes (every one):
load_credentialswith top-level[],[{"client_id":"x"}],"hello",
123,null,true→ rawAttributeError: '<type>' object has no attribute 'get'(neverColdStoreError)load_credentialswithclient_id=123or["x"]→ returned
unchecked (truthiness check at :447 passes)load_statewith top-level[],"hello",123,null→ returned
unchecked;_folder_id/state.get(...)then raise rawAttributeErrorstate.json={"folders": "abc"}→ rawValueError: dictionary update sequence element #0 has length 1;{"folders": 123}→ rawTypeError;
{"folders": ["root"]}→ rawTypeError: list indices must be integersstate.json={"folders": {"bundles": 123}}→_folder_id("bundles")
silently returns123(int, not a Drive id string)
Dedup: searched open + closed issues for cold-store, load_state,
credentials.json corrupt shape. Related but distinct: issue #3279
(torn-write invalid JSON — the fix for that is the corrupt-syntax handling
above), issue #2618 (D1 response shapes, closed), issue #6525/#6531
(repair_dump, open). No issue covers the load_state/load_credentials
shape contract or the folders field shape.
Why it matters
Every cold-store command starts by loading one or both of these files.
A wrong-shape file currently either kills the run with an undiagnosed
traceback (operator cannot tell which file or what shape is wrong) or —
worse for folders — silently substitutes a wrong-typed identifier into
Drive operations in a tool whose job includes pruning and eviction.
Acceptance criteria
-
load_credentialsraisesColdStoreErrornamingcredentials.json
and the unexpected shape (with the existing repair guidance) when the
top level is not a JSON object; no rawAttributeError/TypeError
escapes for any valid-JSON input. - Credential values that are present for the known keys
(client_id,client_secret,refresh_token) must be strings;
a non-string value raises the same namedColdStoreErrorinstead of
passing the truthiness check. -
load_stateraisesColdStoreErrornamingstate.jsonand the
unexpected shape when the top level is not a JSON object. - A present
foldersfield must be an object mapping string keys to
string folder ids; any other shape (string/number/list value, or a
non-string id) raises a namedColdStoreErrorinstead of a raw
downstreamValueError/TypeErroror a silently mistyped id. - New tests in
pkgs/cold-store-reaper/tests/test_cold_store.pycover:
non-object top level for both files, non-string credential value,
non-objectfolders, non-string folder id — plus the existing
corrupt-syntax and happy-path controls still passing. - The full cold-store test suite passes (laptop or CI).
Activity
developing-today commentedon Nov 7, 2026
CODE-2113
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
developing-today commentedon Nov 8, 2026
🤖 Agent note · handed off
developing-today commentedon Nov 8, 2026
🤖 Agent note · handed off
24 remaining items
dezren39 commentedon Nov 9, 2026
agent-note:v1 lane=code-b task=11062 stage=handed_off — Issue #6845 revalidated fresh: OPEN, no hard-stop labels. Task 11062 (small_fix) opencode-assigned (lane row 3542); handing off to opencode claimant, parking 1200s.
🤖 Agent note · handed off
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
opencode(row 3542)dezren39 commentedon Nov 10, 2026
agent-note:v1 — state: handed_off (task 11062, lane code-h)
dezren39 commentedon Nov 10, 2026
agent-note:v1
state: handed-off
queue: repo-health-code-pilot
task: 11062 (small_fix, worker repo-worker-code, lane code-e)
by: repo-worker-code lane code-e
at: 2026-11-10T06:23:59Z
Handed off to the opencode execution lane (assigned_lane=opencode via fleet queue lane, lane row 3542). Fresh check: issue #6845 OPEN, no hard-stop labels (held / user/owned / do-not-merge / do-not-auto-edit absent). Attempts 4/4. AT CAP This lane does not work task 11062 directly. Parked 1200s to release the claim for claimant binding.
dezren39 commentedon Nov 11, 2026
Agent note — picked up (existing PR sheperding path)
dezren39 commentedon Nov 11, 2026
Agent note — done: PR #7552 merged, issue closed
python3 -m unittest discover -s pkgs/cold-store-reaper/tests— 152 tests, OK (1 skipped). The PR had no reviews/Codex findings; its only failing checks were the unrelated fleet-secrets scripts-test cluster.