Skip to content

fix(gemini): depth counter in inline_refs_inner only decrements on $ref resolution#1665

Merged
bug-ops merged 2 commits intomainfrom
gemini-inline-refs-depth
Mar 13, 2026
Merged

fix(gemini): depth counter in inline_refs_inner only decrements on $ref resolution#1665
bug-ops merged 2 commits intomainfrom
gemini-inline-refs-depth

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 13, 2026

Summary

  • inline_refs_inner decremented the depth counter on every structural recursion step (object key / array element), not only on $ref resolution
  • Schemas with 9+ levels of plain nesting hit the depth-8 limit prematurely, corrupting deeply nested schemas even without any $ref cycles
  • Fix: pass depth unchanged when recursing into object/array structure; only decrement on $ref resolution

Test plan

  • New regression test test_inline_refs_deep_plain_nesting: 9-level nested schema with a $ref at the bottom — asserts the ref is resolved to "string", not replaced with the fallback object
  • Existing tests test_inline_refs_simple, test_inline_refs_no_defs, test_inline_refs_depth_limit still pass
  • cargo nextest run --workspace --features full --lib --bins — 5238 passed, 0 failed

Closes #1638. Part of #1592.

…ef resolution

Previously depth was decremented on every object/array structural recursion step,
causing schemas with 9+ levels of plain nesting to hit the depth-8 limit prematurely
even when no $ref was present. Now only $ref resolution consumes a depth slot.

Adds regression test `test_inline_refs_deep_plain_nesting` covering the bug.

Closes #1638.
@github-actions github-actions bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes bug Something isn't working size/S Small PR (11-50 lines) labels Mar 13, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 13, 2026 18:17
@bug-ops bug-ops merged commit e913018 into main Mar 13, 2026
15 checks passed
@bug-ops bug-ops deleted the gemini-inline-refs-depth branch March 13, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/S Small PR (11-50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(gemini): inline_refs_inner depth counter conflates nesting depth with ref-resolution depth

1 participant