Skip to content

fix(server): preserve non-UUID request IDs - #2459

Open
original4422 wants to merge 2 commits into
abetlen:mainfrom
original4422:fix/server-non-uuid-request-id
Open

original4422 wants to merge 2 commits into
abetlen:mainfrom
original4422:fix/server-non-uuid-request-id

Conversation

@original4422

Copy link
Copy Markdown

Summary

X-Request-ID present → preserve its value in context and response
header absent/empty → generate a UUID for this request

Fixes #1337. Reverse proxies can supply legal non-UUID request IDs, but the default UUID validation returned 400 before API handling. A small custom request-ID plugin keeps the existing context middleware, UUID generation and response propagation while accepting those opaque IDs. API-key authentication stays in place.

Evidence

  • Before: the nine new integrated server tests produce six failures and three passing controls on unmodified source.
    After: all nine pass with the real 19 MB stories15M GGUF on CPU, including request context, generated IDs, concurrent isolation, authentication and streaming/non-streaming completions.
  • A separate public CLI server passes 22 actual HTTP checks: non-UUID/UUID/absent headers, mirrored/generated IDs, bearer 401/200, concurrent requests and real CPU completions/SSE with [DONE].
  • LLAMA_CPP_TEST_MODEL=<local tiny GGUF> PYTEST_ADDOPTS="tests/test_server_request_id.py tests/test_llama_chat_format.py tests/test_llama_grammar.py tests/test_llama_speculative.py" make test: 15 passed, none skipped. The nine new tests are included in that count.
  • make lint: Ruff checks and formatting pass on 30 files. The first formatting check identified two changed files; formatting was corrected and the checks rerun.

Validation used macOS arm64, Python 3.12.14, starlette-context 0.3.6, FastAPI 0.165.0 and Starlette 1.10.0, with n_gpu_layers=0. This is the selected four-suite run, not the complete model-downloading suite. No GPU or performance benchmarks were run. Tests needing a model explicitly skip when LLAMA_CPP_TEST_MODEL is absent.

AI-assisted implementation, validation and review by the account owner's authorized proxy.

Merge Danger

Door: two-way.

Blast Radius: correlation.

Client request IDs are no longer constrained to UUID syntax. Legal header values are reflected as correlation metadata; the middleware and API authentication remain enabled.

This branch has not been deployed

No deployments
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.

Allow any format for X-Request-Id

1 participant