Skip to content

Prometheus 401 on the observability query routes reads as an expired NodePilot session #1010

Backlog

Description

@Sev7eNup

Problem

GET /api/observability/query and GET /api/observability/query_range pass the Prometheus status code straight through to the caller (ObservabilityController.cs, new ContentResult { ..., StatusCode = result.StatusCode }). If Prometheus rejects NodePilot's credentials (wrong OpenTelemetry:Prometheus:Password or BearerToken, or basic auth enabled on Prometheus while NodePilot has none configured), the API answers 401 to a client whose session is valid.

np reads any 401 as an expired session (BaseCommand.cs) and prints Session expired. Run np auth login again. Signing in again does not help, because the problem is the upstream credential, not the session. Reproduced on a lab host with basic auth enabled on Prometheus: np auth login succeeded, and the next np observability query reported an expired session.

The SPA client treats every 401 as an auth boundary and redirects to /login (src/nodepilot-ui/src/api/client.ts). The metrics page currently goes through /observability/dashboards/{key}, which wraps Prometheus errors per panel, so it is not affected today. Any future UI caller of the raw query routes would log the user out.

Expected

An upstream authentication failure never looks like a NodePilot session failure. The API maps Prometheus 401/403 to a gateway error (e.g. 502 with a problem body such as code: PROMETHEUS_UNAUTHORIZED) that names the Prometheus credentials as the cause.

Notes

  • Other upstream statuses (400 for a bad PromQL expression, 422, 503) can keep passing through. Only the auth statuses collide with NodePilot's own meaning.
  • Check whether the MCP server's handling of these routes reads a 401 the same way as np.
  • Needs a controller test for the 401 → 502 mapping.

Activity

  1. added
    bug
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions