Skip to content

fix: always fixup schemes of Grafana client based on final Grafana URL #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025

Conversation

sd2k
Copy link
Collaborator

@sd2k sd2k commented Jun 5, 2025

When constructing the Grafana client we need to ensure that it doesn't
try to use HTTPS when the final Grafana URL scheme is HTTP.

This particularly affects the case where the Grafana URL is not
provided and the server is running on SSE mode. This is because:

  • in stdio mode we use ExtractGrafanaClientFromEnv, which falls
    back to explicitly using the defaultGrafanaURL variable if the
    GRAFANA_URL environment variable is not set, so a non-empty value
    is passed to NewGrafanaClient
  • in SSE mode we use ExtractGrafanaClientFromHeaders, which does not
    fall back to defaultGrafanaURL and instead passes an empty string,
    therefore relying on the NewGrafanaClient to use the default
    schemes.

Fixes #162.

When constructing the Grafana client we need to ensure that it doesn't
try to use HTTPS when the final Grafana URL scheme is HTTP.

This particularly affects the case where the Grafana URL is not
provided and the server is running on SSE mode. This is because:

- in stdio mode we use `ExtractGrafanaClientFromEnv`, which falls
  back to explicitly using the `defaultGrafanaURL` variable if the
  GRAFANA_URL environment variable is not set, so a non-empty value
  is passed to `NewGrafanaClient`
- in SSE mode we use `ExtractGrafanaClientFromHeaders`, which does not
  fall back to `defaultGrafanaURL` and instead passes an empty string,
  therefore relying on the `NewGrafanaClient` to use the default
  schemes.

Fixes #162.
@sd2k sd2k requested a review from a team as a code owner June 5, 2025 07:33
@sd2k sd2k merged commit de6926b into main Jun 5, 2025
10 checks passed
@sd2k sd2k deleted the fix-grafana-client-scheme-if-url-not-customised branch June 5, 2025 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants