Commit 93bd732
committed
fix: catch NumberFormatException on CLI numeric options (CodeQL #269-273)
OpenAiCompatServer's CLI main() called Integer.parseInt on --ctx, --gpu-layers,
--parallel and --port without guarding NumberFormatException, so a non-numeric
value (e.g. "--port abc") crashed with a raw stack trace — flagged by CodeQL as
"missing catch of NumberFormatException" (5 alerts).
Consolidate the numeric parsing into one try/catch that prints a clear message and
returns (no System.exit — the noSystemExit architecture rule forbids it; this
mirrors the existing missing-"--model" usage path), and parse --ctx once instead
of twice.
Verified: compiles clean under -Werror / NullAway / Checker; LlamaArchitectureTest
(noSystemExit) passes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014L2dLbAtwdq7C6a2gFRsQQ1 parent cf3e487 commit 93bd732
1 file changed
Lines changed: 30 additions & 21 deletions
Lines changed: 30 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | 355 | | |
| 356 | + | |
369 | 357 | | |
370 | 358 | | |
371 | 359 | | |
372 | 360 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | 361 | | |
378 | 362 | | |
379 | 363 | | |
| |||
382 | 366 | | |
383 | 367 | | |
384 | 368 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
389 | 397 | | |
| 398 | + | |
390 | 399 | | |
391 | 400 | | |
392 | 401 | | |
| |||
0 commit comments