Commit fb74077
committed
fix: validate CLI numeric limits
Motivation:
sjsonnet accepted invalid numeric CLI limits for stack frames, trace cropping, and parser recursion depth. Non-positive stack limits created a broken runtime setting, negative trace limits behaved like an undocumented full-trace setting, and negative parser recursion depth reached the parser as Parsing exceeded maximum recursion depth of -1.
Modification:
Validate --max-stack >= 1, --max-trace >= 0, and --max-parser-recursion-depth >= 0 after CLI parsing and before constructing Settings. Add JVM CLI regression tests for invalid stack, trace, and parser-depth values, and preserve the boundary behavior that --max-trace 0 keeps a full trace and --max-parser-recursion-depth 0 still allows non-recursive expressions.
Result:
Invalid numeric CLI limits now fail before evaluation or parsing with user-facing CLI errors. Stack and trace behavior matches C++ jsonnet and go-jsonnet for shared flags, while the sjsonnet-specific parser-depth flag now rejects only the invalid negative range.
References:
C++ jsonnet cmd/jsonnet.cpp rejects --max-stack < 1 and --max-trace < 0.
go-jsonnet cmd/jsonnet/cmd.go rejects --max-stack < 1 and --max-trace < 0.
sjsonnet readme.md documents --max-parser-recursion-depth without a negative-value meaning.1 parent e686d89 commit fb74077
2 files changed
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
198 | 213 | | |
199 | 214 | | |
200 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
150 | 191 | | |
151 | 192 | | |
152 | 193 | | |
| |||
0 commit comments