Skip to content

fix(schema): contain overflow while preparing external schemas - #160438

Closed
Ayushdevo wants to merge 2 commits into
openclaw:mainfrom
Ayushdevo:fix/schema-validator-rangeerror-160426
Closed

Ayushdevo wants to merge 2 commits into
openclaw:mainfrom
Ayushdevo:fix/schema-validator-rangeerror-160426

Conversation

@Ayushdevo

@Ayushdevo Ayushdevo commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #160426

What Problem This Solves

Fixes: deeply nested external JSON Schemas overflow during preparation instead of producing a usable validation diagnostic.

User Impact

External plugin schemas report invalid schema rather than missing setup. Bundled schema overflows remain loud programming errors.

Why This Change Was Made

Contain RangeError across fingerprinting, schema inspection, normalization, compilation, and defaults metadata. Preserve the unusable-schema classification through plugin config enablement; ordinary value validation and other schema exceptions retain their contracts. No arbitrary size/depth threshold is introduced.

Evidence

Real TypeBox and fingerprint overflows reproduced on main (depth 3,000 and 10,000 fixtures); no compiler mocks. All 82 tests across six schema suites passed (109.32s including cold worker preparation). Final isolated regression suite: 7 passed, 4.72s wall, test execution 51–149ms per case. Actual external config enablement reports invalid; both bundled/external origins are covered. The previously reported smaller shapes now compile on current main, so those old limits are not claimed reproduced. No installed third-party package or live Gateway scenario was exercised.

Independent reviews of the touched contracts found no actionable P0/P1/P2 findings. The repository Auto Review helper was attempted but its source upload was rejected by the host approval review; no external review verdict is claimed.

Core source typing and all core test-type graphs passed in the original checkout. Extension production typing, scoped lint for all touched core/extension TypeScript files, formatting, and git diff --check passed. Restored source files were verified against their submitted commits.

The broader local changed-check completion was lost when the temporary workspace reset, so a complete local changed-check pass is not claimed. The full extension test-type graph and full/qaRuntime builds were OOM-killed on an 8 GiB host; the runtime attempt also failed with compiler threads bounded to two. No successful local full/runtime build or real Gateway/provider proof is claimed.

Hosted CI is green for head 395e32e: https://github.com/openclaw/openclaw/actions/runs/37138266641 . The old-head schema-error classification finding is addressed by this revision and covered by both manifest origins. Fresh ClawSweeper review is on hold because its repository input-safety check could not complete; the bot requests maintainer workflow inspection and no contributor action.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check could not safely complete for this revision.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: No contributor action is requested. Maintainers should inspect the linked workflow run.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 28, 2026, 8:15 AM ET / 12:15 UTC.

ClawSweeper review

What this changes

The branch makes OpenClaw's shared JSON Schema validator return a structured error when schema compilation throws a RangeError.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 5 items remain

The linked bug remains open and current main still lets compiler errors escape. This PR addresses that path, but it misclassifies an unusable schema as an ordinary value failure, and the contributor has supplied no after-fix runtime proof.

Priority: P2
Reviewed head: 23a3203b3e8319dbc8ec3a11378251018fd84eca

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch targets the reported compiler failure, but it changes schema-error classification and has no after-fix behavior proof.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The changed production validator is called by plugin config and tool validation, but the PR supplies no after-fix run of the linked installed-package schema scenario. A redacted terminal trace showing the structured result and caller behavior would establish it; redact private endpoints, addresses, and credentials. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The changed production validator is called by plugin config and tool validation, but the PR supplies no after-fix run of the linked installed-package schema scenario. A redacted terminal trace showing the structured result and caller behavior would establish it; redact private endpoints, addresses, and credentials. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Introduced catch: The pinned PR catches RangeError from compileSchema and returns an ordinary failed validation result.
Existing schema error contract: The manifest wrapper sets schemaError to false for every failed result and to true for an exception from an external schema.
User-visible consequence: Config enablement labels a failure with schemaError false and no configured value as missing setup; an unusable schema cannot be repaired by supplying config.
Findings 1 actionable finding [P2] Preserve the unusable-schema classification
Security None None.

How this fits together

Plugins and other integrations supply JSON Schemas to the shared validator. Its result feeds config readiness, SDK validation, and tool input handling.

flowchart LR
  A[Plugin or tool schema] --> B[Schema shape check]
  B --> C[Compile validator]
  C --> D{Compilation succeeds?}
  D -->|Yes| E[Validate value]
  D -->|No| F[Schema diagnostic]
  E --> G[Config or tool result]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The changed production validator is called by plugin config and tool validation, but the PR supplies no after-fix run of the linked installed-package schema scenario. A redacted terminal trace showing the structured result and caller behavior would establish it; redact private endpoints, addresses, and credentials. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve the unusable-schema classification (P2) - A compilation RangeError now returns { ok: false }, which validatePluginSchemaValue unconditionally marks schemaError: false. With no plugin config, resolvePluginConfigEnablement then reports missing setup even though no value can make this schema compilable. Keep compiler failure distinguishable from value failure and cover both manifest origins.
  • Resolve merge risk (P1) - The catch covers compilation only. Fingerprinting and recursive shape inspection still process the supplied schema first, so the proposed handling does not establish a bound on earlier traversal.
  • Resolve merge risk (P1) - The new failure result changes how bundled and external plugin schemas are classified; upgrade behavior for config readiness needs focused verification.
  • Complete next step (P2) - Repair schema-error classification and demonstrate the reported failure path after the fix in a real setup.

Findings

  • [P2] Preserve the unusable-schema classification — src/plugins/schema-validator.ts:419-426
Agent review details

Security

None.

PR surface

Source +18. Total +18 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 19 1 +18
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 19 1 +18

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #160426
Summary: This PR explicitly proposes a fix for the linked schema-overflow report, which remains open.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Preserve schema failure meaning (recommended)
    Repair the manifest result classification and verify missing-config and bundled-schema behavior before merge.
  2. Pause this approach
    Keep the PR open while a bounded rejection path is worked out if compilation-only handling cannot cover the reported input.

Technical review

Best possible solution:

Reject excessive schema depth or size at the shared validator boundary, preserve the unusable-schema classification for manifest callers, and verify the published-package failure path.

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

No current-main execution was performed. The linked report gives a concrete installed-package trigger, and current-main source shows the unguarded compiler call.

Is this the best way to solve the issue?

No. Catching compiler RangeError is useful, but the shared validator should reject excessive schemas before recursive processing and retain the distinction between schema and value failures.

Full review comments:

  • [P2] Preserve the unusable-schema classification — src/plugins/schema-validator.ts:419-426
    A compilation RangeError now returns { ok: false }, which validatePluginSchemaValue unconditionally marks schemaError: false. With no plugin config, resolvePluginConfigEnablement then reports missing setup even though no value can make this schema compilable. Keep compiler failure distinguishable from value failure and cover both manifest origins.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2da0e9a4c85b.

Labels

Label changes:

  • add P2: This is a bounded validation failure with a concrete linked report, but the demonstrated trigger requires an extreme externally supplied schema.
  • add merge-risk: 🚨 compatibility: The patch changes an unusable plugin schema from an exception into a value failure that callers classify differently.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed production validator is called by plugin config and tool validation, but the PR supplies no after-fix run of the linked installed-package schema scenario. A redacted terminal trace showing the structured result and caller behavior would establish it; redact private endpoints, addresses, and credentials. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a bounded validation failure with a concrete linked report, but the demonstrated trigger requires an extreme externally supplied schema.
  • merge-risk: 🚨 compatibility: The patch changes an unusable plugin schema from an exception into a value failure that callers classify differently.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed production validator is called by plugin config and tool validation, but the PR supplies no after-fix run of the linked installed-package schema scenario. A redacted terminal trace showing the structured result and caller behavior would establish it; redact private endpoints, addresses, and credentials. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Preserve schema-error classification across manifest callers and cover the existing readiness contract.
  • Provide a redacted real-package run showing the reported schema now produces the intended result.

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.

Copy link
Copy Markdown
Contributor Author

Independent review: the compiler-overflow result must remain distinguishable from ordinary value validation failures. Otherwise validatePluginSchemaValue can mark an unusable schema as schemaError:false, and config enablement may report “missing” even though no supplied value can make the schema compile. Please preserve that classification and add synthetic coverage for both bundled and external origins. I found no credentials or private data in this review.

@Ayushdevo
Ayushdevo requested a review from a team as a code owner October 3, 2026 16:49
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: whatsapp-web Channel integration: whatsapp-web channel: zalouser Channel integration: zalouser app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime extensions: copilot-proxy Extension: copilot-proxy labels Oct 3, 2026
@obviyus

obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Ayushdevo. We tested this through a real built Gateway on current main (50d7eb1), and with your branch merged onto main:

  • Deep plugin session-action schemas (depth 480/2000/12000) are rejected at registration, and their RPCs return UNAVAILABLE. The Gateway stays up.
  • A plugin tool with a depth-2000 parameters schema fails the agent turn with "Maximum call stack size exceeded". This happens in stable-stringify (stringifyObjectValue/stringifyStableValue, then withRuntimeToolSchemaQuarantine), before validateJsonSchemaValue or TypeBox runs. The Gateway stays up, and no provider request is sent.
  • That happens identically with this branch merged, because the overflow is in a different owner than the validator this PR changes.

So the crash loop from #160426 doesn't reproduce on main, and this PR doesn't change the failure that remains. Closing this one. If you'd like to take the remaining case (deep tool schemas overflowing stable-stringify), a fix in that owner would be welcome.

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

Labels

app: android App: android app: ios App: ios app: linux app: macos App: macos app: wearos App: wearos app: web-ui App: web-ui channel: a2a channel: buzz channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: irc channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: qa-channel Channel integration: qa-channel channel: reef Channel integration: reef channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: whatsapp-web Channel integration: whatsapp-web channel: zalouser Channel integration: zalouser docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: acpx extensions: active-memory extensions: admin-http-rpc extensions: agentsapi extensions: alibaba extensions: amazon-bedrock extensions: amazon-bedrock-mantle extensions: anthropic extensions: anthropic-vertex extensions: apple-fm extensions: arcee extensions: baseten Extension: baseten extensions: brave extensions: browser extensions: byteplus extensions: canvas extensions: cerebras extensions: chutes extensions: clawrouter Extension: clawrouter extensions: clickclack extensions: cloudflare extensions: cloudflare-ai-gateway extensions: codex extensions: cohere extensions: comfy extensions: copilot extensions: copilot-proxy Extension: copilot-proxy extensions: crabbox extensions: deepinfra extensions: fish-audio Extension: fish-audio extensions: github GitHub plugin: link previews and reader extensions: kie extensions: novita extensions: openai extensions: qa-lab extensions: tts-local-cli gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: azure-speech Azure Speech plugin plugin: beam Beam session sharing plugin plugin: bonjour Plugin integration: bonjour plugin: code-mode-quickjs plugin: file-transfer plugin: imap plugin: slack-huddles plugin: workboard rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security Security documentation size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Deeply nested external tool schema crashes validateJsonSchemaValue with RangeError

2 participants