Skip to content

Comments

fix(auth): add error_tracking_read OAuth2 scope for error-tracking commands#46

Draft
platinummonkey wants to merge 1 commit intomainfrom
fix/error-tracking-oauth-scope
Draft

fix(auth): add error_tracking_read OAuth2 scope for error-tracking commands#46
platinummonkey wants to merge 1 commit intomainfrom
fix/error-tracking-oauth-scope

Conversation

@platinummonkey
Copy link
Collaborator

Summary

Adds the error_tracking_read OAuth2 scope to enable error-tracking commands when using OAuth2 authentication. Resolves authentication issues where error-tracking commands would fail with 401 Unauthorized when using OAuth2.

Changes

  • pkg/auth/types/types.go:103 - Added error_tracking_read to DefaultScopes()
  • pkg/auth/types/types_test.go:176 - Updated test expectations for new scope
  • docs/OAUTH2.md:227 - Documented the error_tracking_read scope
  • docs/TROUBLESHOOTING.md:109 - Added comprehensive OAuth2 troubleshooting section for error-tracking
  • cmd/error_tracking.go:34 - Updated help text with authentication notes

Background

The error-tracking commands (pup error-tracking issues search|get) were implemented without adding the required OAuth2 scope. According to Datadog's API documentation, the error_tracking_read scope is required for Error Tracking API endpoints.

Scope Availability Note

While the error_tracking_read scope is documented and valid, there may be edge cases where Datadog's OAuth2 authorization endpoint rejects it during login (e.g., for DCR clients or certain org configurations). The PR includes comprehensive troubleshooting documentation with an API key authentication workaround.

Testing

# Run unit tests
go test ./pkg/auth/types/... -v
go test -run TestErrorTracking ./cmd/... -v

# Manual OAuth2 flow test (requires Datadog account)
pup auth logout
pup auth login  # Should succeed with new scope
pup error-tracking issues search --from=1d

All existing tests pass. The new scope is validated in TestDefaultScopes().

Related Issues

Closes #45


🤖 Generated with Claude Code

…mmands

Add the `error_tracking_read` OAuth2 scope to the default scopes list to
enable error-tracking commands when using OAuth2 authentication.

Changes:
- Add `error_tracking_read` to DefaultScopes() in pkg/auth/types/types.go:103
- Update test expectations in pkg/auth/types/types_test.go:176
- Document the scope in docs/OAUTH2.md:227
- Add OAuth2 troubleshooting section in docs/TROUBLESHOOTING.md:109
- Update error-tracking command help text with auth notes

The scope is documented in Datadog's API reference:
https://docs.datadoghq.com/api/latest/scopes/

Note: There may be edge cases where Datadog's OAuth2 authorization endpoint
rejects this scope (e.g., for certain org configurations or DCR limitations).
Added comprehensive troubleshooting documentation with API key workaround.

Closes #45

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@platinummonkey platinummonkey requested review from a team as code owners February 11, 2026 20:13
@platinummonkey
Copy link
Collaborator Author

Note: this is blocked until this route is properly included in OAuth scopes in the backend.

@github-actions
Copy link

📊 Test Coverage Report

Overall Coverage: 81.7% Coverage

Threshold: 80% ✅

Coverage by Package
## Coverage by Package

- github.com/DataDog/pup/pkg/auth/callback/server.go:40: 81.2%
- github.com/DataDog/pup/pkg/auth/dcr/client.go:28: 100.0%
- github.com/DataDog/pup/pkg/auth/dcr/types.go:24: 100.0%
- github.com/DataDog/pup/pkg/auth/oauth/client.go:22: 100.0%
- github.com/DataDog/pup/pkg/auth/oauth/pkce.go:24: 85.7%
- github.com/DataDog/pup/pkg/auth/storage/factory.go:53: 94.7%
- github.com/DataDog/pup/pkg/auth/storage/keychain.go:44: 42.9%
- github.com/DataDog/pup/pkg/auth/storage/storage.go:58: 71.4%
- github.com/DataDog/pup/pkg/auth/types/types.go:23: 100.0%
- github.com/DataDog/pup/pkg/client/client.go:32: 94.4%
- github.com/DataDog/pup/pkg/config/alias.go:26: 100.0%
- github.com/DataDog/pup/pkg/config/config.go:22: 100.0%
- github.com/DataDog/pup/pkg/formatter/formatter.go:31: 100.0%
- github.com/DataDog/pup/pkg/useragent/useragent.go:32: 100.0%
- github.com/DataDog/pup/pkg/util/time.go:20: 95.8%

## Summary

total:								(statements)		81.7%

📈 Coverage Status: ✅ PASSED - Coverage meets minimum threshold

Updated for commit 157a4e3

@platinummonkey platinummonkey marked this pull request as draft February 11, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] error-tracking endpoint + oauth

1 participant