Conversation
…level (#760) The schema normalization module logged a WARN on every tool schema that used a non-Draft-2020-12 `$schema` URI (e.g. draft-07 from Attio MCP tools). Two problems: 1. `$schema` was only stripped from the root of the parameters object. `json_schema_ast` validates `$schema` at every nesting level, so schemas with `$schema` inside nested `definitions`/`$defs` would still fail canonicalization and fall through to the WARN path. 2. The fallback log level was `warn!`, but this is an expected state for non-standard schemas where the fallback works correctly. Per the project's logging conventions, `debug!` is appropriate for "detailed diagnostics" rather than "unexpected but recoverable." Fix: replace root-only stripping with `strip_schema_keyword_recursive` that removes `$schema` from all levels, and downgrade the three fallback log statements from `warn!` to `debug!`. Entire-Checkpoint: d9484974c5c2
Greptile SummaryFixes repeated WARN-level log spam (#760) caused by Confidence Score: 5/5Safe to merge — targeted fix with no correctness risk and two regression tests that verify the non-fallback code path. No P0/P1 findings. The recursive stripping is correct (handles objects and arrays, removes $schema before recursing into sibling values). The debug! downgrade matches CLAUDE.md conventions for expected-recoverable states. Both new tests are well-designed: they detect the fallback path indirectly via the lower_boolean_and_null_types canonicalization side-effect, and the PR description confirms they failed before the fix. No files require special attention.
|
| Filename | Overview |
|---|---|
| crates/providers/src/openai_compat/schema_normalization.rs | Adds recursive $schema stripping via strip_schema_keyword_recursive and downgrades three fallback log levels from warn! to debug! — both changes are correct and align with project conventions. |
| crates/providers/src/openai_compat/tests.rs | Adds two well-designed regression tests that verify canonicalization runs (not the fallback path) by asserting the lower_boolean_and_null_types side-effect (enum: [false, true]) is present after sanitization. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["sanitize_schema_for_openai_compat(schema)"] --> B["canonicalize_schema_for_openai_compat(schema)"]
B --> C["schema.clone() → input"]
C --> D["strip_schema_keyword_recursive(&mut input)\n(NEW: recurses into objects + arrays)"]
D --> E["SchemaDocument::from_json(&input)"]
E -->|Err| F["debug! preflight failed\nreturn input as-is"]
E -->|Ok| G["document.root()"]
G -->|Err| H["debug! AST resolution failed\nreturn input as-is"]
G -->|Ok| I["document.canonical_schema_json()"]
I -->|Err| J["debug! canonicalization unavailable\nreturn input as-is"]
I -->|Ok| K["canonical serde_json::Value"]
K --> L["Schema::try_from(canonical)"]
L --> M["Apply schemars transforms\nReplaceConst / ReplaceUnevaluatedProperties\nReplacePrefixItems / RemoveRefSiblings\nOpenAiSchemaSubset / SimplifyComposite\nPruneOrphanedRequired / RestoreEnumType"]
M --> N["*schema = transformed.to_value()"]
Reviews (1): Last reviewed commit: "fix(providers): strip $schema recursivel..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Fixes #760 — schema normalization WARN logs repeated 1000+ times per session.
$schemastripping:json_schema_astvalidates$schemaat every nesting level, so root-only stripping was insufficient for schemas with$schemainside nesteddefinitions/$defs(e.g. Attio MCP tools). Now strips recursively before canonicalization.warn!was inappropriate for an expected state. Changed todebug!per project logging conventions.Validation
Completed
cargo +nightly-2025-11-30 fmt --all -- --checkjust lint(clippy clean)just test(367 tests pass)sanitize_draft07_nested_definitions_schema_canonicalized— verifies schemas with$schemain nesteddefinitionsgo through full canonicalization (not fallback)sanitize_draft07_schema_uses_canonicalization_not_fallback— verifies root-level draft-07 schemas also trigger canonicalizationManual QA
moltis servewith an OpenAI-compatible provider (e.g. OpenRouter)~/.config/moltis/logs.jsonl— no more WARN spam fromschema_normalization🤖 Generated with Claude Code