← Back to Pull requests

feat(server): add response identity headers #20268

Closed
unknown closed this pull request without merging on Sep 10, 2026 06:06 UTC
View on GitHub
unknown unknown commented on Sep 05, 2026 04:08 UTC
Author

Description

This PR adds opt-in response headers that identify the Druid process which generated an HTTP response:

  • X-Druid-Server: advertised host and port

  • X-Druid-Service: configured druid.service name

  • X-Druid-Version: Druid version
  • The feature is disabled by default and can be enabled with:

    druid.server.http.enableResponseIdentityHeaders=true
    

    The identity handler wraps the complete Jetty handler chain and restores the headers after downstream response resets, so locally generated responses, including early HTTP errors, receive the headers when enabled.

    Proxy behavior

    For query and management requests proxied by a Router:

  • If the upstream returns all three identity headers, the Router forwards the upstream identity.

  • If the upstream returns none or only a partial set, the Router returns no identity headers.

  • If no upstream response is received and the Router generates the response, the headers identify the Router.

  • A Router with the feature disabled suppresses upstream identity headers.
  • Treating the three headers as an all-or-nothing triple prevents clients from receiving an ambiguous partial identity.

    The standalone Coordinator's /druid/indexer/* proxy to a separate Overlord follows the same contract, so it forwards a complete Overlord identity without mixing it with the Coordinator identity.

    Security

    The headers can reveal internal hostnames, IP addresses, ports, and the Druid version. The setting remains disabled by default and should only be enabled when clients are authorized to receive this information.

    Automated tests

  • 51 focused configuration, handler, management-proxy, and query-proxy tests passed.

  • ResponseIdentityHeaderTest: 6 embedded end-to-end tests passed.

  • The embedded coverage includes Coordinator and Overlord APIs directly and through Router, the standalone Coordinator-to-Overlord proxy, Broker SQL and native queries directly and through Router, a native query directly to Historical, and Router-generated responses.

  • git diff --check passed.
  • Real nano cluster validation

    The feature was tested against a locally built apache-druid-39.0.0-SNAPSHOT nano-quickstart cluster. All 16 requests returned the expected status and complete identity triple.

    | URL | Request | Status | X-Druid-Server | X-Druid-Service | X-Druid-Version |
    |---|---|---:|---|---|---|
    | http://localhost:8888/status/health | Router health | 200 | localhost:8888 | druid/router | 39.0.0-SNAPSHOT |
    | http://localhost:8082/status/health | Broker health | 200 | localhost:8082 | druid/broker | 39.0.0-SNAPSHOT |
    | http://localhost:8081/status/health | Coordinator/Overlord health | 200 | localhost:8081 | druid/coordinator | 39.0.0-SNAPSHOT |
    | http://localhost:8083/status/health | Historical health | 200 | localhost:8083 | druid/historical | 39.0.0-SNAPSHOT |
    | http://localhost:8091/status/health | Middle Manager health | 200 | localhost:8091 | druid/middleManager | 39.0.0-SNAPSHOT |
    | http://localhost:8081/druid/coordinator/v1/isLeader | Coordinator API direct | 200 | localhost:8081 | druid/coordinator | 39.0.0-SNAPSHOT |
    | http://localhost:8888/druid/coordinator/v1/isLeader | Coordinator API via Router | 200 | localhost:8081 | druid/coordinator | 39.0.0-SNAPSHOT |
    | http://localhost:8081/druid/indexer/v1/isLeader | Overlord API direct | 200 | localhost:8081 | druid/coordinator | 39.0.0-SNAPSHOT |
    | http://localhost:8888/druid/indexer/v1/isLeader | Overlord API via Router | 200 | localhost:8081 | druid/coordinator | 39.0.0-SNAPSHOT |
    | http://localhost:8082/druid/v2/sql | SQL direct to Broker | 200 | localhost:8082 | druid/broker | 39.0.0-SNAPSHOT |
    | http://localhost:8888/druid/v2/sql | SQL via Router | 200 | localhost:8082 | druid/broker | 39.0.0-SNAPSHOT |
    | http://localhost:8082/druid/v2 | Native query direct to Broker | 200 | localhost:8082 | druid/broker | 39.0.0-SNAPSHOT |
    | http://localhost:8888/druid/v2 | Native query via Router | 200 | localhost:8082 | druid/broker | 39.0.0-SNAPSHOT |
    | http://localhost:8083/druid/v2 | Native query direct to Historical | 200 | localhost:8083 | druid/historical | 39.0.0-SNAPSHOT |
    | http://localhost:8888/status/health | Router-generated PATCH rejection | 405 | localhost:8888 | druid/router | 39.0.0-SNAPSHOT |
    | http://localhost:8888/not-a-druid-endpoint | Router-generated missing endpoint | 404 | localhost:8888 | druid/router | 39.0.0-SNAPSHOT |

    The nano configuration runs Coordinator and Overlord in one process on port 8081 with druid.service=druid/coordinator, so requests to Overlord endpoints correctly report that process identity.

    Release note

    Druid can optionally return X-Druid-Server, X-Druid-Service, and X-Druid-Version on HTTP responses, allowing operators to identify the process and version that served a direct or Router-proxied request. Enable the feature with druid.server.http.enableResponseIdentityHeaders=true only for clients permitted to receive cluster topology and version information.

    <hr>

    ##### Key changed/added classes in this PR

  • ResponseIdentityHeaderHandler

  • OverlordProxyServlet

  • AsyncManagementForwardingServlet

  • AsyncQueryForwardingServlet

  • ResponseIdentityHeaderTest
  • <hr>

    This PR has:

  • been self-reviewed.

  • added documentation for new or modified features or behaviors.

  • a release note entry in the PR description.

  • added comments explaining the "why" and the intent of the code wherever it would not be obvious for an unfamiliar reader.

  • added unit tests or modified existing tests to cover new code paths.

  • added integration tests.

  • been tested in a test Druid cluster.
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: GWphua Review duration: 7317m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #20268"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%
    Repository