Repository navigation
fix(usage): guard malformed DeepSeek balance payloads - #110785
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 26, 2026, 3:51 AM ET / 07:51 UTC. ClawSweeper reviewWhat this changesThe PR guards DeepSeek balance parsing so successful Merge readinessThis is still a useful, unmerged two-file hardening fix for malformed successful DeepSeek responses. The supplied regression coverage and real loopback HTTP result support ordinary maintainer review; no concrete patch defect or security concern is visible in the provided current-head evidence. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s provider-usage fetchers call provider billing endpoints and normalize their responses into usage snapshots for downstream usage displays. This DeepSeek adapter converts a successful balance response into summary, billing, and availability fields while preserving a stable empty snapshot when balance data is unavailable. flowchart LR
A[Usage refresh] --> B[DeepSeek balance endpoint]
B --> C[HTTP response parser]
C --> D{Record-shaped payload?}
D -->|Yes| E[Normalize balance fields]
D -->|No| F[Empty usage snapshot]
E --> G[Usage display consumers]
F --> G[Usage display consumers]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1, Tests +12. Total +13 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep the record-shape guard and its regression cases, then land it once a maintainer is satisfied with the current-head review and required checks. Do we have a high-confidence way to reproduce the issue? Yes, at source level: a successful DeepSeek HTTP response whose JSON root is Is this the best way to solve the issue? Yes. Validating the top-level parsed value at the provider adapter boundary is the narrowest maintainable fix and retains the established empty-snapshot behavior for absent balance data. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5347285d6bc4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
059ae2d to
8d339b4
Compare
8d339b4 to
2c60276
Compare
|
Merged via squash.
|
* origin/main: (224 commits) fix(memory): preserve Windows session ownership (openclaw#115851) fix(compaction): drop context-engine fallback on codex ownership skip (openclaw#114155) (openclaw#115666) fix(msteams): ignore blank certificate settings (openclaw#109112) fix(usage): guard malformed DeepSeek payloads (openclaw#110785) docs(agents): reword imported review rules in repo voice docs(agents): add context-budget, tool-description, cache-invalidation, and review-premise rules docs(agents): mock-gateway proof satisfies gate without discouraging live proof docs(agents): add vitest in-flight edit rule and mock-gateway proof recipe docs(agents): restructure root AGENTS.md around product doctrine and deduped policy fix(codex): keep completed answers over audit gaps (openclaw#115849) test(cli): isolate unknown-command process validation (openclaw#115848) fix(memory-host-sdk): resolve stable execPath for worker fork to survive Homebrew Node upgrades (openclaw#99318) feat(ui): add composer capability menu (openclaw#115800) fix(synology-chat): stop fabricating send message ids (openclaw#110770) fix(feishu): reply to direct messages by chat id (openclaw#109637) fix(acp): attach error listener to spawned ACP agent process (openclaw#109529) fix(sessions): deliver agent announcements to direct message sessions (openclaw#115811) fix(nextcloud-talk): reject reactions for disabled or unconfigured accounts (openclaw#112675) refactor(ui): move Agent Defaults entry from the sidebar into the Agents page (openclaw#115836) feat(gateway): push session PR indicators to subscribed clients (openclaw#115643) ... # Conflicts: # src/agents/apply-patch.ts # src/agents/sandbox/fs-bridge-mutation-helper.ts
* origin/main: fix(usage): guard malformed DeepSeek payloads (openclaw#110785)
Co-authored-by: Leon-SK668 <[email protected]>
* origin/main: fix(usage): guard malformed DeepSeek payloads (openclaw#110785)
What Problem This Solves
Fixes an issue where users viewing DeepSeek usage could hit an uncaught
TypeErrorwhen the balance endpoint returned a successful JSON payload with a non-object top-level shape such asnullor an array.Why This Change Was Made
The usage parser now accepts only record-shaped successful payloads before reading balance fields. Non-object payloads follow the existing
No balance datasnapshot contract, while valid balance records and unavailable-account handling remain unchanged.User Impact
DeepSeek usage refreshes degrade to a stable empty usage result instead of rejecting when the upstream returns a malformed successful payload. The endpoint's documented object/
balance_infosshape remains unchanged: https://api-docs.deepseek.com/api/get-user-balance/Evidence
upstream/main@faf3dbdda833b36d4cccf465a40aabe2d1675d3dnode scripts/run-vitest.mjs src/infra/provider-usage.fetch.deepseek.test.ts- 1 file / 7 tests passed.oxfmt --check src/infra/provider-usage.fetch.deepseek.ts src/infra/provider-usage.fetch.deepseek.test.ts- passed.git diff --check- passed.node:httploopback server returning HTTP 200null(no DeepSeek credential or external provider call):{ "transport": "real-node-http-loopback", "request": {"method": "GET", "url": "/user/balance", "authHeaderPresent": true}, "result": {"provider": "deepseek", "windows": 0, "error": "No balance data"} }AI-assisted contribution; the behavior, owner boundary, and validation were reviewed before submission.