Commit f684d27
authored
feat: introduce maximum parser recursion depth (#483)
Resolves issue #473.
This PR implements a configurable maximum parser recursion depth limit
to prevent stack overflow from deeply
nested Jsonnet structures, following the approach from
[google/jsonnet#1230](google/jsonnet#1230)
**Changes**
- Added maxParserRecursionDepth: Int = 1000 parameter to Settings class
- Added --max-parser-recursion-depth CLI argument to allow runtime
configuration
- Updated Settings flow: CLI → Config → Settings → Interpreter →
CachedResolver → Parser
**Before:**
- Parsing extremely deeply nested structures (e.g., [[[...1000+
levels...]]]) could cause native stack
overflow and crash the interpreter.
**After:**
- Parser gracefully throws java.lang.Exception: Parsing exceeded maximum
recursion depth of 1000 instead of
crashing.
- Users can now configure the limit: `sjsonnet
--max-parser-recursion-depth 2000 deeply_nested.jsonnet`
- Allows tuning for specific use cases while maintaining safe defaults1 parent 8e13eb6 commit f684d27
File tree
6 files changed
+454
-315
lines changed- sjsonnet
- src-jvm-native/sjsonnet
- src/sjsonnet
6 files changed
+454
-315
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
142 | 148 | | |
143 | 149 | | |
144 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
| 289 | + | |
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
| 209 | + | |
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
217 | | - | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
0 commit comments