api7 / api7/aisix

cleanup: unify request-id header to `x-aisix-request-id` across all endpoints

Open
#194 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

priority-normal
Dominant language
Rust
Stars
157
Forks
32
Avg merge
1h 25m
Merged PRs (30d)
145

Description

Summary

Today the gateway emits two different response headers for the server-issued request id, depending on which endpoint handled the request:

  • `x-aisix-request-id` — emitted by `/v1/messages`, `/v1/responses`, `/v1/rerank`, `/v1/audio/`, `/passthrough/`
  • `x-aisix-call-id` — emitted only by `/v1/chat/completions` (single insert at `crates/aisix-proxy/src/chat.rs:122`)
  • (no request-id header) — `/v1/completions`, `/v1/embeddings`, `/v1/images/generations`, `/v1/models`

The intent of the header is identical across endpoints — give the operator a UUID to echo when filing tickets — so the split header name is purely accidental drift.

Why this matters

  • Operators grepping logs / dashboards / SDK error reports for one name miss requests served by the other endpoint.
  • Customer SDKs that try to surface "which request did this trace?" can't do it uniformly.
  • The split is documented as a known wart in docs/api-proxy.md §3 (added in #191), but the long-term fix is code-side convergence.

Proposed fix

  1. Change `crates/aisix-proxy/src/chat.rs:122` to insert `x-aisix-request-id` instead of `x-aisix-call-id`.
  2. Add the header to the four endpoints that emit nothing today: `/v1/completions`, `/v1/embeddings`, `/v1/images/generations`, `/v1/models`. Each handler already has a `request_id` UUID in scope; just `response.headers_mut().insert("x-aisix-request-id", hv)` before returning.
  3. Update `docs/api-proxy.md` §3 to drop the `x-aisix-call-id` row once the chat handler is converged.
  4. Backwards-compat: emit BOTH `x-aisix-call-id` and `x-aisix-request-id` from chat for one release if any internal tooling grep-matches the legacy name.

Severity

LOW: cosmetic / observability convergence. No functional impact on request handling.

Audit trail

Surfaced by the doc-vs-code audit on PR #191 (HIGH-3 finding: "9/10 endpoints" claim was wrong; real distribution is 5 / 1 / 4 / 0 across the four header states).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in crates/aisix-proxy/src/chat.rs at line 122, then locate the handlers for /v1/completions, /v1/embeddings, /v1/images/generations, and /v1/models. Verify how each response is built and where its request_id is available. Done means all listed endpoints emit x-aisix-request-id, chat no longer relies only on x-aisix-call-id, and docs/api-proxy.md §3 reflects the unified behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, observability
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.