Repository navigation
Description
Problem
pkgs/cold-store-reaper/cold_store.py parses the OAuth token endpoint's
HTTP-200 responses with a bare json.loads(resp) and unchecked field
access in both auth flows — the exact assumption the D1 paths in the same
file were hardened against in issue #2618 (which added the guarded
_d1_parse_payload helper at :259-285). The token paths never got it:
auth_exchange(:648, payload at :667):payload.get("refresh_token")
on whateverjson.loadsreturned. A list body raises a raw
AttributeError; a non-JSON 200 body raises a rawJSONDecodeError.
(A dict body missingrefresh_tokenis handled with a named
ColdStoreError— the intended pattern, already present one line down.)access_token(:678, payload at :708): the payload is subscripted for
the token field andexpires_inis added to the current timestamp with
no shape checks at all:- dict body missing the token field → raw
KeyError - list body → raw
TypeError: list indices must be integers;
string body → rawTypeError: string indices must be integers - non-JSON 200 body → raw
JSONDecodeError expires_inas a string ornull→ rawTypeError: unsupported operand type(s) for +: 'float' and 'str'/'NoneType'when computing
the in-memory expiry- a non-string token value (e.g.
123) is returned unchecked and flows
into theAuthorization: Bearer …header built by_auth_headers
- dict body missing the token field → raw
Every cold-store command goes through access_token() before touching
Drive/S3/D1, so a shape-drifted 200 from the token endpoint (or an
intermediary/proxy answering in its place — the transport layer in this
same file documents exactly that class of intermediary misbehavior for
S3) kills the run with a traceback that names neither the endpoint nor
the unexpected shape, instead of the module's own ColdStoreError.
Evidence (verified this run)
Laptop primary ~/git/code at origin/main
65beb42c1a70672bed159fe401c2cb1079aa516f. Probe:
~/git/fleet/probe-cold-store-state/probe_token.py (+ probe_token2.py)
against the real cold_store.py copied verbatim from origin/main
(sha256 39a1ecb1a8ff10dedcb59538cc6d2691d7a264e3def2afcb41963240dea27f2d),
with http_request stubbed to return HTTP 200 with canned bodies and a
fixture credentials file — no network, no real credentials.
Controls (as expected):
access_tokenwith{"access_token": "…", "expires_in": 3600}→ token
returned, expiry setauth_exchangewith a dict carryingrefresh_token→ stored, returned
summary; dict withoutrefresh_token→ namedColdStoreError
(re-run-the-grant guidance)
Failing shapes:
access_token: missing token field → rawKeyError; token123→
returned unchecked;expires_in"3600"ornull→ rawTypeError;
body[]/"hello"→ rawTypeError; bodynot json→ raw
JSONDecodeErrorauth_exchange: body[]→ rawAttributeError: 'list' object has no attribute 'get'; bodynot json→ rawJSONDecodeError
Dedup: searched open + closed issues for cold-store token response shape, access_token ColdStoreError — no hits. Issue #2618 covers only
the D1 response paths (d1_error_message / _d1_select / sync loop) and
its fix added _d1_parse_payload in this same file; the token-endpoint
paths at :667/:708 do not use it. Issue #6845 (filed this run) covers the
local files load_state/load_credentials, a different input surface.
Why it matters
access_token() is on the critical path of every command. When the token
endpoint's 200 body drifts in shape, the operator currently gets a raw
KeyError/TypeError/JSONDecodeError with no indication that the
token response was the problem — and a non-string token silently
propagates into the Authorization header of every subsequent request.
Acceptance criteria
- Both token-response parses (
auth_exchange:667,access_token
:708) validate the payload shape — reusing or mirroring the
_d1_parse_payloadpattern from cold-store-reaper: D1 response handling assumes object shapes throughout — array/string bodies and non-object errors/result entries raise AttributeError instead of ColdStoreError #2618 — so a non-JSON or
non-object 200 body raises aColdStoreErrornaming the token
endpoint and the unexpected shape; no raw
JSONDecodeError/AttributeError/TypeErrorescapes. -
access_token: a missing or non-string token field raises the
namedColdStoreError; a presentexpires_inmust be a number —
a string/null/object value raises the named error instead of a
raw arithmeticTypeError(absentexpires_inkeeps the existing
3600 default). -
auth_exchange: the existing missing-refresh_token
ColdStoreErrorbehaviour is preserved, and a non-string
refresh_tokenvalue is refused the same way rather than written
intocredentials.json. - New tests in
pkgs/cold-store-reaper/tests/test_cold_store.py
(transport stubbed, as in the probe) cover: non-JSON body, list
body, missing token field, non-string token, string/null
expires_inforaccess_token; list body and non-JSON body for
auth_exchange; happy-path controls still pass. - The full cold-store test suite passes (laptop or CI).
Activity
developing-today commentedon Nov 7, 2026
CODE-2114
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
developing-today commentedon Nov 8, 2026
🤖 Agent note · picked up
developing-today commentedon Nov 8, 2026
🤖 Agent note · done
queue/11063-6846-cold-store-token-shapeWhat landed in PR #7001
auth_exchange,access_token) now go through_d1_parse_payloadwith flow-named messages — non-JSON/non-object 200 bodies raiseColdStoreErrornaming the flow and shape (cold-store-reaper: D1 response handling assumes object shapes throughout — array/string bodies and non-object errors/result entries raise AttributeError instead of ColdStoreError #2618 pattern).access_token: missing/non-string token refused by name;expires_inmust be a number when present (3600 default preserved).auth_exchange: missing-refresh_tokenerror preserved; non-stringrefresh_tokenrefused, never written tocredentials.json.TestTokenResponseShapes); full suitepython3 -m unittest discover -s pkgs/cold-store-reaper/tests— 146 tests OK (1 skipped) on the laptop.Note: PR #7001 was created through the developing.today GitHub App (fleet_paperwork REST route) because the user token's GraphQL rate limit is exceeded this shift; the branch push and all verification are unaffected.
16 remaining items
developing-today commentedon Nov 8, 2026
🤖 Agent note · parked
dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up
fix(cold-store): validate token-response shape in both auth flows (#6846
dezren39 commentedon Nov 8, 2026
🤖 Agent note · done