Skip to content

feat: set the function-call depth limit at every parse entry point, up to 512 - #255

Merged
kvlonge merged 1 commit into
mainfrom
fix/call-depth-limits
Nov 18, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/call-depth-limits

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Why

Generated SQL, such as a macro that nests about 65 REPLACE calls, can go past the library's function-call depth limit, and only Rust callers could raise it. Lint parsed with its own fixed limit of 128. A depth refusal did not say how to raise the limit.

Changes

  • --max-call-depth on check, convert, run, function and census; max_call_depth= on Python's check and ConvertOptions; max_function_call_depth on a lint request, like a format request.
  • Lint's default rises from 128 to 256, the same as every other entry point. No public default is lowered.
  • A limit runs from 1 to 512, the parser's fixed nesting ceiling. A larger value is refused at the argument, naming the ceiling.
  • A nested-call refusal names the depth and the limit and says how to raise it for that entry point (the flag, the keyword or the request field), up to 512. A refusal at the ceiling says that no setting raises it.
  • The depth guard stays: nesting past any limit is a clean parse error, never a stack overflow.

Verification

  • Rust tests on a 256 KiB thread: 256, 300 and 511 levels parse with a fitting limit; 257, 301 and 600 give a clean error with the hint, and the ceiling refusal names 512.
  • CLI, Python and lint tests cover the flag, the keyword, the request field, the hints and the refusal above 512; lint reads 256 levels by default and refuses 257.
  • The wheel smoke test in the distributions workflow reads 511 levels on a small-stack thread on every platform, Windows included.
  • make check-ci RECORDER=0 passes.

…p to 512

Generated SQL can nest function calls deeper than the default limit of
256, and only Rust callers could raise it. The check, convert, run,
function and census commands now take --max-call-depth, Python's check
and convert take max_call_depth=, and a lint request takes
max_function_call_depth, whose default rises from 128 to 256 to match
the other entry points.

A limit runs from 1 to 512, the parser's fixed nesting ceiling, and a
larger one is refused, naming the ceiling. A refusal for nested calls
says how to raise the limit for its entry point, and one that meets the
ceiling says that no setting raises it.

The parser grows its stack as it nests, so a raised limit stays safe.
Rust tests on a 256 KiB thread read 256, 300 and 511 levels and refuse
257, 301 and 600 cleanly; CLI, Python and lint tests cover the flag,
the keyword, the request field and the hints; and the wheel smoke test
reads 511 levels on a small thread on every platform, Windows included.
@kvlonge
kvlonge enabled auto-merge November 18, 2026 16:11
@kvlonge
kvlonge disabled auto-merge November 18, 2026 16:40
@kvlonge
kvlonge added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit bf55b2b Nov 18, 2026
14 checks passed
@kvlonge
kvlonge deleted the fix/call-depth-limits branch November 18, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant