feat(synthetics): accept OAuth2 for synthetics tests run - #653
Merged
platinummonkey merged 1 commit intoJul 17, 2026
Merged
Conversation
`synthetics tests run` was the only synthetics command that could not
authenticate with an OAuth2 session (`pup auth login`). Its
`build_auth_headers` hard-required DD_API_KEY + DD_APP_KEY and never read
`cfg.access_token`, unlike every sibling command which routes through
`make_dd_client`/`apply_auth` and prefers a bearer token.
The Datadog CI endpoints this command calls (`synthetics/ci/tunnel`,
`synthetics/tests/trigger/ci`, `synthetics/ci/batch/{id}`) already accept
OAuth2 bearer tokens with the `synthetics_write`/`synthetics_read` scopes,
which pup requests by default — so this was a client-side gap, not a
backend limitation.
- Prefer OAuth2 bearer, fall back to API + app keys, mirroring
`client::apply_auth`.
- Clearer error when no auth is configured.
- Add positive/negative tests for the three auth paths.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jaluna0
marked this pull request as ready for review
July 17, 2026 19:53
platinummonkey
approved these changes
Jul 17, 2026
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
synthetics tests runis the only synthetics command that rejects an OAuth2 session (pup auth login). It hard-requiresDD_API_KEY+DD_APP_KEY, while every sibling command works with a bearer token. This makes it accept OAuth2 too — preferring the bearer, falling back to keys.Why
tests_runbuilds its ownreqwest::Clientand itsbuild_auth_headersonly ever setdd-api-key/dd-application-key— it never readscfg.access_token. Every other synthetics command routes throughmake_dd_client/apply_auth, which prefers the bearer.The Datadog CI endpoints this command calls already accept OAuth2 server-side (verified in dogweb):
GET /synthetics/ci/tunnelSYNTHETICS_WRITEorCREATE_EDIT_TRIGGERPOST /synthetics/tests/trigger/ciSYNTHETICS_WRITEorCREATE_EDIT_TRIGGERGET /synthetics/ci/batch/{id}SYNTHETICS_READpup already requests
synthetics_write/synthetics_readby default. So this was a client-side gap, not a backend limit — no backend change required, and it applies to--tunnelruns too.Changes
build_auth_headers(src/commands/synthetics.rs): prefer OAuth2 bearer, fall back to API + app keys, mirroringclient::apply_auth.Testing