Skip to content

fix(plugin-sdk): contextualize malformed provider catalogs - #109754

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
krissding:fix/guard-network-response-json-parse
Aug 30, 2026
Merged

vincentkoc merged 1 commit into
openclaw:mainfrom
krissding:fix/guard-network-response-json-parse

Conversation

@krissding

@krissding krissding commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators using live provider model discovery could receive a raw JSON parser error when a provider returned a malformed successful response. The error did not identify the provider operation, and reflected request credentials could appear in the parser cause.

Why This Change Was Made

Live model catalog responses now use the canonical bounded provider JSON reader. Ordinary discovery errors include the provider ID, redact reflected request headers from parser causes, and retain the existing 4 MiB limit. The anonymous shared upstream catalog keeps its useful SyntaxError cause and separate 8 MiB limit. Existing fatal UTF-8/BOM handling, stall diagnostics, response release, pagination, anonymous 401 retry, and static fallback behavior remain unchanged.

The original proposal also changed Google prompt-cache parsing. Those unrelated edits were removed from this PR. Invalid Google cache creation degrading to uncached streaming remains a separate follow-up.

User Impact

Malformed provider catalog responses now produce actionable errors such as provider model discovery: malformed JSON response without exposing reflected credentials. Shared anonymous catalog failures identify upstream-provider-catalog while retaining the parser cause for diagnosis.

Evidence

  • Before: the production catalog entry point exposed a raw SyntaxError; custom JSON overflow callbacks were ignored.
  • After: malformed first and paginated responses include provider context, suppress reflected fake credentials, and release every guarded response.
  • A sanitized TCP fixture exercises pagination through the actual fetch guard.
  • Focused provider/catalog tests: 82 passed.
  • Anonymous 401 retry tests: 2 passed.
  • Plugin contract tests: 1108 passed.
  • Plugin SDK exports, surface budget, boundaries, deadcode, formatting, lint, and max-lines checks passed.
  • Independent verification and structured autoreview found no actionable findings.
  • Production LOC: +18/-14, net +4. Existing pagination tests were moved verbatim to a focused test file for the max-lines gate.
  • Reviewed head: 8825ac6fafa16361d677c442a56aa7a857343447.

The full local build completed runtime, packages, external plugins, CLI bootstrap, postbuild, and all 148 public Plugin SDK export checks. UI loading and core-test typechecking were blocked by unrelated shared node_modules drift (pako 1.0.11 installed versus 3.0.1 required); dependencies were intentionally not reconciled in the isolated worktree. Hosted exact-head CI and Testbox are the authoritative clean-environment gates.

The final commit preserves @krissding's authorship with:

Co-authored-by: krissding <[email protected]>

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Jul 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 5:38 AM ET / 09:38 UTC.

ClawSweeper review

What this changes

The branch routes live provider catalog parsing through the shared bounded JSON reader so malformed responses identify the catalog operation and do not retain credential-bearing parser causes.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: current main still exposes raw catalog parser failures, while this focused patch centralizes bounded parsing, context, and credential-safe error handling without a concrete introduced regression.

Priority: P2
Reviewed head: 8825ac6fafa16361d677c442a56aa7a857343447

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, owner-aligned repair with meaningful guarded-transport coverage and no actionable introduced defect found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The changed production owner is the live catalog reader; the supplied local-TCP test drives its paginated request through the real SSRF fetch guard and observes the after-fix contextualized, credential-safe error.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed production owner is the live catalog reader; the supplied local-TCP test drives its paginated request through the real SSRF fetch guard and observes the after-fix contextualized, credential-safe error.
Evidence reviewed 6 items Current-main behavior remains unfixed: Current main directly decodes and parses the catalog response, so malformed JSON still escapes as the raw parser/decoder error.
Introduced owner-boundary repair: The PR replaces the duplicate decode/parse path with the canonical provider JSON reader and supplies the provider-specific label and actual request headers.
Credential-safe cause handling: The shared reader retains fatal UTF-8 decoding and wraps parser failures, omitting the cause only when request headers could contain credentials.
Findings None None.
Security None None.

How this fits together

Live provider discovery fetches and paginates model catalogs before provider plugins project those models into runtime configuration. The changed reader is the boundary between guarded HTTP responses and catalog parsing.

flowchart LR
  A[Provider catalog endpoint] --> B[Guarded HTTP fetch]
  B --> C[Bounded JSON reader]
  C --> D[Catalog parsing]
  D --> E[Pagination]
  E --> F[Runtime model configuration]
Loading

Before merge

  • Resolve merge risk (P1) - This exported SDK runtime intentionally changes malformed authenticated catalog failures from a raw parser error to a contextual Error without its original cause; direct third-party consumers that classify that error shape need compatibility awareness.
  • Resolve merge risk (P1) - Exact-head hosted checks were still pending in the supplied context, so normal merge gating remains required.
  • Complete next step (P2) - No discrete automated repair remains; await exact-head CI and the normal maintainer merge gate.
Agent review details

Security

None.

PR surface

Source +4, Tests +158. Total +162 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 18 14 +4
Tests 4 308 150 +158
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 326 164 +162

Review metrics

Metric Value Why it matters
Production versus test delta production +4 net (+18/-14); tests +158 net (+308/-150) The small production increase carries labels and request-header context into an existing canonical reader; most test growth is regression coverage and a pagination-test relocation.
Exported error path 1 Plugin SDK runtime subpath behavior changed Malformed catalog errors become contextual and credential-safe for direct consumers of the exported runtime module.

Stored data model

Persistent data-model change detected: serialized state: src/plugin-sdk/provider-catalog-live-runtime.ts, unknown-data-model-change: src/plugin-sdk/provider-catalog-live-runtime.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept the intentional error normalization (recommended)
    Merge after exact-head checks pass, treating contextual credential-safe malformed-response errors as the supported SDK behavior.
  2. Pause for an SDK error-contract decision
    If third-party callers are expected to distinguish raw parser causes, define and document that public error contract before merging.

Technical review

Best possible solution:

Land the focused shared-reader reuse after exact-head checks pass, retaining the anonymous upstream catalog’s parser cause, explicit eight-megabyte ceiling, and existing static fallbacks.

Do we have a high-confidence way to reproduce the issue?

Yes: the supplied local-TCP guarded-fetch scenario reaches the real discovery owner through pagination and asserts the post-fix error behavior; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: reusing the existing bounded provider JSON reader removes duplicate parsing while retaining limits, fatal decoding, release behavior, and provider static fallbacks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8b7d685b2a92.

Labels

Label changes:

  • add P2: Malformed provider catalog responses currently give limited diagnostics and can affect configured provider discovery, but static fallbacks contain the normal runtime impact.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the live catalog reader; the supplied local-TCP test drives its paginated request through the real SSRF fetch guard and observes the after-fix contextualized, credential-safe error.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed production owner is the live catalog reader; the supplied local-TCP test drives its paginated request through the real SSRF fetch guard and observes the after-fix contextualized, credential-safe error.
  • remove P1: Current review triage priority is P2, so this older priority label is no longer current.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 auth-provider: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Malformed provider catalog responses currently give limited diagnostics and can affect configured provider discovery, but static fallbacks contain the normal runtime impact.
  • merge-risk: 🚨 compatibility: An exported Plugin SDK runtime now normalizes malformed authenticated-response errors differently, including suppression of parser causes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed production owner is the live catalog reader; the supplied local-TCP test drives its paginated request through the real SSRF fetch guard and observes the after-fix contextualized, credential-safe error.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the live catalog reader; the supplied local-TCP test drives its paginated request through the real SSRF fetch guard and observes the after-fix contextualized, credential-safe error.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-12T17:23:34.492Z sha 91d22d33b29c5c879689f42872f5201dacb43bb7 :: needs real behavior proof before merge. :: [P1] Retain fatal UTF-8 decoding | [P1] Fall back when optional cache creation returns malformed JSON | [P2] Name the failing provider in catalog parse errors
  • reviewed 2026-08-14T10:07:58.489Z sha 91d22d33b29c5c879689f42872f5201dacb43bb7 :: needs real behavior proof before merge. :: [P1] Preserve fatal UTF-8 decoding | [P1] Keep malformed cache creation optional | [P2] Include the provider in catalog parse errors
  • reviewed 2026-08-15T13:19:25.461Z sha 91d22d33b29c5c879689f42872f5201dacb43bb7 :: needs real behavior proof before merge. :: [P1] Preserve fatal UTF-8 decoding | [P1] Keep malformed cache creation optional | [P2] Include the provider in catalog parse errors
  • reviewed 2026-08-16T22:19:08.761Z sha 91d22d33b29c5c879689f42872f5201dacb43bb7 :: needs real behavior proof before merge. :: [P1] Preserve fatal UTF-8 decoding | [P1] Keep malformed cache creation optional | [P2] Name the catalog provider in the parse error
  • reviewed 2026-08-18T12:37:35.906Z sha 91d22d33b29c5c879689f42872f5201dacb43bb7 :: needs real behavior proof before merge. :: [P1] Preserve fatal UTF-8 decoding | [P1] Keep malformed cache creation optional | [P2] Name the catalog provider in parse errors
  • reviewed 2026-08-24T01:25:34.981Z sha 91d22d33b29c5c879689f42872f5201dacb43bb7 :: needs real behavior proof before merge. :: [P1] Preserve fatal UTF-8 decoding | [P1] Keep malformed cache creation optional | [P2] Include the catalog provider in the parse error
  • reviewed 2026-08-25T03:52:48.344Z sha 91d22d33b29c5c879689f42872f5201dacb43bb7 :: needs real behavior proof before merge. :: [P1] Preserve fatal UTF-8 decoding | [P1] Keep malformed cache creation optional | [P2] Name the catalog provider in parse errors
  • reviewed 2026-08-27T14:30:29.113Z sha 91d22d33b29c5c879689f42872f5201dacb43bb7 :: needs real behavior proof before merge. :: [P1] Preserve fatal UTF-8 decoding | [P1] Keep malformed cache creation optional | [P2] Name the catalog provider in parse errors

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. and removed P2 Normal backlog priority with limited blast radius. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 27, 2026
@vincentkoc
vincentkoc force-pushed the fix/guard-network-response-json-parse branch from 91d22d3 to 8825ac6 Compare August 30, 2026 09:30
@vincentkoc vincentkoc self-assigned this Aug 30, 2026
@vincentkoc vincentkoc changed the title fix: guard JSON.parse against malformed network response bodies fix(plugin-sdk): contextualize malformed provider catalogs Aug 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Reviewed head: 8825ac6fafa16361d677c442a56aa7a857343447

Before-merge and rank-up dispositions from the August 27 review:

  • Add real behavior proof: addressed. The PR body includes the trusted production-entry before/after reproduction, and the tests include a sanitized paginated malformed response through the actual guarded fetch path.
  • Preserve fatal UTF-8 decoding: addressed. Catalog decoding now delegates to the canonical provider JSON reader, which retains fatal UTF-8 and BOM behavior; existing invalid UTF-8 coverage passes.
  • Keep malformed cache creation optional: the unrelated Google prompt-cache edits were removed entirely. Uncached-streaming degradation remains a named follow-up, not part of this PR.
  • Name the catalog provider in parse errors: addressed with the ordinary ${providerId} model discovery label. The fixed anonymous feed uses upstream-provider-catalog.
  • Resolve merge risk (conflicts): addressed. GitHub reports the replacement head mergeable; the approved commit also merges cleanly with current main.
  • Resolve merge risk (proof): addressed by the updated PR body and actual guarded-fetch fixture.
  • Complete next step: addressed by the maintainer replacement implementation, focused validation, independent verification, and native review artifacts.
  • Improve patch quality (contracts): addressed. Fatal decoding is preserved and the Google cache changes are absent.
  • Improve patch quality (proof/re-review): addressed by the production-boundary evidence above and this re-review request.

Validation: 82 focused provider/catalog tests, 2 anonymous-401 tests, and 1108 plugin contract tests passed. Plugin SDK surface, boundary, deadcode, lint, format, and max-lines checks are clean. Production delta is +18/-14 (net +4). Structured autoreview and independent verification found no issues.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 30, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member

ClawSweeper current-head dispositions for 8825ac6fafa16361d677c442a56aa7a857343447:

  • Exported error-path compatibility: accepted as the intentional, reviewed scope. Only malformed authenticated catalog responses change from raw parser failures to contextual credential-safe errors; no public API or error class is added, anonymous upstream parsing retains its SyntaxError cause, and existing fallback behavior is preserved.
  • Exact-head hosted checks: required and still being awaited. Merge will not proceed unless the checks for this exact head are green.
  • Maintainer next step: no automated repair remains. Run the required Testbox prepare gate, then merge-verify and merge-run --auto-merge only after all gates pass.
  • Rank-up moves: none were listed in the August 30 current-head review.

@vincentkoc
vincentkoc merged commit 8c74ad9 into openclaw:main Aug 30, 2026
271 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants