Repository navigation
fix(clawrouter): show stable error for malformed usage responses - #119580
vincentkoc merged 2 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 9:17 AM ET / 13:17 UTC. ClawSweeper reviewWhat this changesThe PR makes malformed ClawRouter quota JSON, invalid UTF-8, and non-object roots produce a stable usage-error snapshot instead of a parser exception. Merge readinessNo blocking findings. The exact head fixes the current malformed-payload throw at the provider-owned parsing boundary, resolves the prior canonical-helper finding, and preserves distinct HTTP and body-read failures. Priority: P2 Review scores
Verification
How this fits togetherClawRouter is a bundled provider plugin that fetches quota data and returns a provider usage snapshot for OpenClaw’s usage display. The changed boundary converts a bounded HTTP response body into either quota data or a user-visible error snapshot. flowchart LR
A[Usage refresh] --> B[ClawRouter plugin]
B --> C[Usage endpoint response]
C --> D[Bounded body reader]
D --> E[JSON and record validation]
E --> F[Usage snapshot]
E --> G[Stable malformed-response snapshot]
F --> H[Provider usage display]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +11, Tests +41. Total +52 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Merge the provider-local parsing repair once normal exact-head CI and GitHub merge gates complete; retain the bounded body-read failures as distinct errors. Do we have a high-confidence way to reproduce the issue? Yes: current main’s fatal decode and JSON parse are outside a catch at the implicated boundary, and the submitted before/after loopback proof exercises that same production function. Is this the best way to solve the issue? Yes: handling only decode, JSON, and root-shape failures after the bounded read is the narrowest maintainable fix; copying a broader sibling catch would wrongly normalize stream and size failures. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d85920c03e25. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Punchcard-Session: clear-orchard-lantern-bc
|
@clawsweeper re-review Applied the durable rank-up move on exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* origin/main: (130 commits) refactor(qa): consolidate scenario runtime helpers (openclaw#119623) fix(telegram): bind Mini App auth to dashboard launches refactor(agent-core): unify session projection and compaction summaries (openclaw#119639) fix(codex): allow natural reactions in the current conversation (openclaw#119649) refactor(providers): deduplicate bundled model catalogs (openclaw#119627) fix(ui): observe the active service worker after asset refresh (openclaw#119622) fix(agents): strip echoed base64 image payloads so photo-heavy turns no longer hit the per-turn output cap (openclaw#119488) improve: make state-heavy test suites faster (openclaw#119617) perf(agents): add concurrency benchmark (openclaw#119569) fix(browser): visibly report failed pairing and tab-sharing actions (openclaw#119526) refactor(lobster): consolidate embedded workflow execution (openclaw#119630) fix(plugin-sdk): stabilize tuple-derived API baseline ordering (openclaw#119635) docs(skills): make full-authority maintainer runs unattended (openclaw#119629) fix(managed-child): honor process groups that vanish before cleanup (openclaw#119614) fix(ci): stop label-driven automation churn (openclaw#119610) fix(media): keep the ttl sweep out of the managed outgoing tree (openclaw#119127) fix(claws): remove owner-qualified skills (openclaw#119606) fix(clawrouter): show stable error for malformed usage responses (openclaw#119580) fix(gateway): claim malformed plugin icon routes (openclaw#119559) fix(telegram): preserve truthful empty-content delivery (openclaw#88810) ...
…nclaw#119580) * fix(clawrouter): handle malformed usage responses * fix(clawrouter): use canonical usage record coercion Punchcard-Session: clear-orchard-lantern-bc --------- Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Fixes an issue where users viewing ClawRouter quota information would get a thrown parsing error when the usage endpoint returned malformed JSON or invalid UTF-8.
Why This Change Was Made
ClawRouter now follows the established Venice and OpenRouter usage pattern by reporting malformed payloads as a stable provider error snapshot. Response-size, stream, HTTP, and transport failures remain distinct errors.
User Impact
Users see “Malformed usage response” instead of a failed quota refresh when ClawRouter returns an invalid payload.
Evidence
node scripts/run-vitest.mjs extensions/clawrouter/usage.test.ts: focused tests pass, including malformed JSON, invalid UTF-8, non-object JSON, stream failure, size cap, HTTP error, and production transport cases.node --import tsx proof-live.ts: the same real production provider path ran against a loopback HTTP boundary on the validation base and exact head.proof-live.ts
AI-assisted: built with Codex
Maintainer exact-head validation (
a02622f369867d32180fe267b19c19e731eeb91b):asOptionalRecordrepair applied without widening the response-read catchPunchcard-Session: clear-orchard-lantern-bc