Commit 72ec437
committed
Fix: Return 'invalid_prompt' error type for invalid token IDs
RVT (ROCm Validation Tool) Spec 2.9 requires POST /v1/completions with an
integer-array prompt to reject invalid token IDs with HTTP 400 and
error.type "invalid_prompt".
Previously, invalid token IDs correctly returned HTTP 400 but used error.type
"invalid_request_error" instead of the spec-required "invalid_prompt".
Changes:
- Add ERROR_TYPE_INVALID_PROMPT to enum error_type (server-common.h)
- Map it to "invalid_prompt" / HTTP 400 (server-common.cpp)
- Use it for range + type validation errors (server-context.cpp)
Invalid token types now properly rejected:
- Out-of-vocabulary (t >= n_vocab)
- Negative values (t < -1)
- LLAMA_TOKEN_NULL (-1) without valid media chunk
- Non-integer JSON types (float, string, null, boolean)1 parent 03d2068 commit 72ec437
3 files changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1709 | 1709 | | |
1710 | 1710 | | |
1711 | 1711 | | |
1712 | | - | |
| 1712 | + | |
1713 | 1713 | | |
1714 | 1714 | | |
1715 | 1715 | | |
| |||
2172 | 2172 | | |
2173 | 2173 | | |
2174 | 2174 | | |
2175 | | - | |
| 2175 | + | |
2176 | 2176 | | |
2177 | 2177 | | |
2178 | 2178 | | |
| |||
0 commit comments