Repository navigation
Description
cold-store-reaper: Drive API response bodies are parsed unguarded — a wrong-shape 200 from files.list / files.create / files.get raises raw Attribute/Key/Type/Value/JSONDecode errors, not ColdStoreError
Summary
pkgs/cold-store-reaper/cold_store.py treats every Google Drive API response body as if it were the exact JSON object the happy path returns. Only HTTP status is checked; the parsed body's shape never is. A 200 response whose body is valid JSON of the wrong shape (or not JSON at all) crashes the caller with a raw builtin exception instead of the module's own ColdStoreError, so the CLI surfaces a traceback and — worse — upload() dies after the bundle has been uploaded and marked uploading, with no verification verdict recorded.
The module already knows the right pattern: put_backup's identical files.get verification readback wraps its parse in try/except (KeyError, TypeError, ValueError) and re-raises its verification_failed ColdStoreError (cold_store.py:1196-1204). The Drive call sites below never got the same guard. This is the Drive-API sibling of #6846 (token endpoints, cold_store.py:667/708) and #6845 (local state/credentials files); the D1 surface was guarded earlier (#2618). Umbrella: #3068.
Unguarded sites (all at main 65beb42)
_find_folder(cold_store.py:735):files = json.loads(resp).get("files", []), thenfiles[0]["id"]._create_folder(cold_store.py:750):return json.loads(resp)["id"]._resumable_upload(cold_store.py:988):file_id = json.loads(resp)["id"]on the 200/201 chunk-completion response.uploadverification readback (cold_store.py:1066-1068):info = json.loads(resp);drive_size = int(info.get("size", -1))— compare the guarded twin input_backupat :1196-1204.list_backups(cold_store.py:1257-1267):page = json.loads(resp);page.get("files", []); per entryf["id"],f["name"],int(f.get("size") or 0).get_backup(cold_store.py:1431-1435): same.get("files", [])+files[0]["id"]pattern as_find_folder.
Verified this run (laptop probe, real cold_store.py verbatim, stubbed transport, @65beb42c1a)
Probe: ~/git/fleet/probe-cold-store-drive (cold_store.py + schema.sql copied verbatim, http_request stubbed, controls pass). Results:
| Call | Wrong-shape 200 body | Observed |
|---|---|---|
_find_folder control {"files":[{"id":"abc"}]} / {} |
— | returns "abc" / None |
_find_folder |
["x"] or "hello" |
raw AttributeError: 'list'/'str' object has no attribute 'get' |
_find_folder |
{"files":"abc"} |
raw TypeError: string indices must be integers |
_find_folder |
{"files":[123]} |
raw TypeError: 'int' object is not subscriptable |
_find_folder |
{"files":[{"name":"n"}]} |
raw KeyError: 'id' |
_find_folder |
not json |
raw JSONDecodeError |
_create_folder control {"id":"new1"} |
— | returns "new1" |
_create_folder |
{} |
raw KeyError: 'id' |
_create_folder |
["x"] |
raw TypeError: list indices must be integers |
list_backups control (one well-formed file entry) |
— | returns the entry |
list_backups |
["x"] (page) |
raw AttributeError: 'list' object has no attribute 'get' |
list_backups |
{"files":["abc"]} |
raw TypeError: string indices must be integers |
list_backups |
{"files":[{"name":"n","size":"1"}]} |
raw KeyError: 'id' |
list_backups |
{"files":[{"id":"f1","name":"n","size":"abc"}]} |
raw ValueError: invalid literal for int() |
get_backup |
{"files":"abc"} |
raw TypeError: string indices must be integers |
upload readback (real pack()-seeded bundle, _resumable_upload stubbed) |
["x"] |
raw AttributeError: 'list' object has no attribute 'get' |
upload readback |
{"size":"abc","md5Checksum":"x"} |
raw ValueError: invalid literal for int() |
upload readback |
not json |
raw JSONDecodeError |
upload readback control (correct size + md5) |
— | returns verified: True |
Why it matters
- Every one of these paths is on the nightly backup/restore route:
ensure_folders(via_find_folder/_create_folder) runs before uploads,list_backupsfeeds retention planning inprune_backups, andget_backupis the restore path. A proxy error page, a partial/truncated body, or an API change returning an error object with a 200 turns a diagnosableColdStoreErrorinto an unhandled traceback that names no endpoint and no expectation. upload()is the worst case: the bundle row is alreadyuploadingand the bytes are already in Drive when the readback parse crashes, so the run dies mid-verification — neither verified nor failed — exactly the state ambiguityput_backup's guarded readback (and its trash-on-failure cleanup) was built to avoid.- The inconsistency itself is the trap: a reader who checks
put_backupreasonably concludes Drive readbacks are guarded everywhere.
Acceptance criteria
- Every Drive response parse listed above validates the parsed shape (object at top level;
filesa list of objects;id/namepresent strings;sizenumeric) and raisesColdStoreErrornaming the operation and what was wrong — no rawAttributeError/KeyError/TypeError/ValueError/JSONDecodeErrorescapes a Drive call site. -
upload()'s verification readback gets the same treatment asput_backup's: an unparseable/wrong-shape readback is a verification failure (ColdStoreError), not a crash after upload. - Well-formed responses behave exactly as today (existing FakeDrive test suite passes unchanged in behavior).
- New tests in
pkgs/cold-store-reaper/tests/test_cold_store.pycover the wrong-shape bodies above for folder find/create, list_backups, get_backup, and the upload readback, assertingColdStoreError(oracle: the guardedput_backupreadback at cold_store.py:1196-1204).
Activity
developing-today commentedon Nov 7, 2026
CODE-2123
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 8, 2026
🤖 Agent note · handed off
34 remaining items
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off to opencode claimant
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off (task 11081, lane code-u)
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off to opencode claimant — Agent: queue worker (repo-worker-code), lane code-w — Session/ID: task 11081, repo-queue-worker-shift-w 2026-11-10 run. Task 11081 (small_fix) for issue #6855: cold-store-reaper: Drive API response bodies are parsed unguarded — a wrong-shape 200 from files.list / files.create / files.get raises raw Attribute/Key/Type/Value/JSONDecode errors, not ColdStoreError; attempts 4/4 on this claim. Fresh check: issue #6855 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels, no status/needs-triage. Execution lane row 3552 = opencode. Checkpointed handed_off (handoff reason: scheduled shift is time-bounded; claimant is the persistent execution session); parking task 11081 for 20 minutes for the claimant window.
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
opencodetest(cold-store): property-based coverage for Drive response parsers (#…
Merge pull request #7135 from developing-today/queue/11081-6855-cold-…
dezren39 commentedon Nov 10, 2026
🤖 Agent note · done — task 14672 fixed_merged (lane code-l, 2026-11-10)
89a083eacf3bd3e6d64100d8ffebd37d3062ae98. Issue cold-store-reaper: Drive API response bodies are parsed unguarded — a wrong-shape 200 from files.list / files.create / files.get raises raw Attribute/Key/Type/Value/JSONDecode errors, not ColdStoreError #6855 is closed by this note: the PR implements its full scope — Drive response bodies for files.list / files.create / files.get are parsed through the_drive_*validators and wrong-shape 200s now raiseColdStoreError, not raw Attribute/Key/Type/Value/JSONDecode errors.046c73563e). The one Codex P1 finding (property-based coverage for the parsers, per the repo testing doctrine) was FIXED inf6480532b8: newTestDriveResponseShapesPropertywith seeded generation and explicit reference oracles for all five validators, plus the no-exception-but-ColdStoreError invariant; the review thread was replied to and resolved.python3 -m unittest tests.test_cold_store— 125 tests OK (1 skipped) at the pre-merge head; Drive-shape classes (example + property, 10 tests) re-run OK on the merged head. GitHub PR-tier checks were still pending in the fleet runner backlog at merge; merged under the standing merge authority on local verification.dezren39 commentedon Nov 11, 2026
🤖 Agent note · done (already_done)
Verified already done on fresh reads: PR #7135 "fix(cold-store): validate Drive response shapes (#6855)" MERGED 2026-11-10T22:38:26Z (shepherded by task 14672, lane code-l), and issue #6855 is CLOSED with status:done. No duplicate work opened. Task 11081 completes as already_done.