Commit c7b383c
fix(backend): don't crash the whole process on an invalid cutstrings/extract_regex (#10855)
Finetune() compiled every model cutstrings/extract_regex entry via regexp.Compile
and called xlog.Fatal on failure, which terminates the entire local-ai process.
A single model config with an invalid regex (e.g. cutstrings: ["("]) turns one
/v1/chat/completions request into a process-level denial of service.
Log the compile error and skip the offending pattern instead. The mutex is
released before continuing, and skipping avoids dereferencing the nil regexp
that removing the fatal would otherwise leave behind.
Fixes #10843
Signed-off-by: Tai An <antai12232931@outlook.com>
Signed-off-by: Richard Palethorpe <io@richiejp.com>1 parent be3d263 commit c7b383c
1 file changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
467 | 469 | | |
468 | 470 | | |
469 | 471 | | |
| |||
480 | 482 | | |
481 | 483 | | |
482 | 484 | | |
483 | | - | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
484 | 488 | | |
485 | 489 | | |
486 | 490 | | |
| |||
0 commit comments