Skip to content

Fix: Return 'invalid_prompt' error type for invalid token IDs - #100

Open
amd-callumm wants to merge 1 commit into
AMD-Ecosystem:gfx11from
amd-callumm:callumm/http_bad_ids
Open

Fix: Return 'invalid_prompt' error type for invalid token IDs#100
amd-callumm wants to merge 1 commit into
AMD-Ecosystem:gfx11from
amd-callumm:callumm/http_bad_ids

Conversation

@amd-callumm

Copy link
Copy Markdown

Overview

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".

Additional information

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)

Tested with a local script (one-time; likely not worth checking in).

Invalid token types are 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)

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES - used to create the test script and to draft the commit message (reviewed and finalized by Callum Mitchell)

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant