Skip to content

Add configurable User-Agent header for Sentry API requests#166

Open
maxmaxme wants to merge 1 commit intoopenai:mainfrom
maxmaxme:sentry-useragent
Open

Add configurable User-Agent header for Sentry API requests#166
maxmaxme wants to merge 1 commit intoopenai:mainfrom
maxmaxme:sentry-useragent

Conversation

@maxmaxme
Copy link

Summary

This PR adds configurable User-Agent support to the Sentry skill API script to improve compatibility with Cloudflare/WAF-protected self-hosted Sentry instances.

What changed

  • Added a default browser-like User-Agent constant.
  • Added global CLI argument: --user-agent.
  • Added environment variable support: SENTRY_USER_AGENT.
  • Propagated user_agent through request helpers and handlers.
  • Added the User-Agent header to all HTTP requests.

Why

Some Sentry endpoints behind Cloudflare can block requests made with the default Python urllib signature (HTTP 403 / Cloudflare 1010).
Allowing a configurable User-Agent makes the script usable in these environments without changing auth/token logic.

Backward compatibility

  • Existing commands continue to work unchanged.
  • If --user-agent / SENTRY_USER_AGENT is not provided, a safe default is used.

Example

python3 scripts/sentry_api.py \
  --base-url https://sentry.example.com \
  --user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" \
  issue-detail 132932519

@maxmaxme maxmaxme requested a review from a team February 14, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant