fix(metrics): require DD_API_KEY for metrics submit command#75
Merged
platinummonkey merged 1 commit intomainfrom Feb 17, 2026
Merged
fix(metrics): require DD_API_KEY for metrics submit command#75platinummonkey merged 1 commit intomainfrom
platinummonkey merged 1 commit intomainfrom
Conversation
The Datadog metrics intake API does not support OAuth2 bearer tokens, only API key authentication. Add a pre-emptive check before client creation to give users a clear, actionable error message when DD_API_KEY is not set, instead of a generic authentication failure. - Check cfg.APIKey before creating the client - Use apiKeyClientFactory to force API key auth (skip OAuth) - Add dedicated test for missing API key scenario Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Datadog metrics intake API requires API key authentication — OAuth2 bearer tokens are not supported for metric submission. This PR adds a pre-emptive check that gives users (and agents) a clear, actionable error message when
DD_API_KEYis not set, instead of failing later with a confusing auth error.Changes
runMetricsSubmitbefore client creation (cmd/metrics.go:833)apiKeyClientFactoryinstead ofgetClient()to force API key auth, skipping OAuth (cmd/metrics.go:845)TestRunMetricsSubmit_RequiresAPIKeytest for the missing API key scenario (cmd/metrics_test.go:630)apiKeyClientFactoryinsetupMetricsTestClienthelper for consistent test behavior (cmd/metrics_test.go:50)Testing
DD_API_KEYand explains the requirementgo test ./...)🤖 Generated with Claude Code