Skip to content

Send discovery agent errors to GlitchTip as well as Sentry (WEB-6914) - #446

Merged
anonpran merged 2 commits into
stagingfrom
web-6914-discovery-glitchtip-dual-send
Nov 30, 2026
Merged

anonpran merged 2 commits into
stagingfrom
web-6914-discovery-glitchtip-dual-send

Conversation

@anonpran

@anonpran anonpran commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The discovery agent now posts every error event to GlitchTip (project coding-discovery-prod) as well as Sentry, with the same event_id, for the Sentry vs GlitchTip trial.
  • Sentry stays the primary. The GlitchTip copy is best-effort and its failures are ignored.
  • Linear: WEB-6914

Changes

Change File
_GLITCHTIP_DSN, plus _post_sentry_event (the existing curl call, extracted) and _copy_event_to_glitchtip scripts/coding_discovery_tools/utils.py
GlitchTip has its own failure counter (stops after 3 in a row per run), reset with the rest of the run state scripts/coding_discovery_tools/utils.py
The copy uses what is left of the caller's max_seconds budget and is skipped when under 1 second scripts/coding_discovery_tools/utils.py
The copy is off whenever AI_DISCOVERY_SENTRY_DSN is set, so pointing Sentry at another project never copies into prod GlitchTip scripts/coding_discovery_tools/utils.py
Tests: AI_DISCOVERY_SENTRY_DSN defaults to empty for every test process and its children, which turns off Sentry and the copy tests/__init__.py
Six tests for the copy: same event reaches both (real local servers), off when the Sentry DSN is overridden, blocked GlitchTip leaves Sentry on, copy still goes when the Sentry post raises, time budget, nothing sent when Sentry is off tests/test_discovery_flow.py

Good to know

  • The copy sits behind the existing Sentry DSN and CI/local-run checks, so anything that silences Sentry silences GlitchTip too.
  • On a network that blackholes sentry.unboundsecurity.ai, a run spends at most about 12 extra seconds (3 attempts of 3 s, plus one for the end-of-run priority event) before the counter stops further attempts.
  • Once Sentry's own failure counter trips, the copy stops with it for that run, apart from the end-of-run priority event.
  • curl runs without -f, as before, so an HTTP 4xx from either host still counts as sent. Delivery is checked server side by comparing event IDs.

Why: leadership wants to move from Sentry to self-hosted GlitchTip, and this agent is the only active Sentry project that was not in the trial.

🤖 Generated with Claude Code

Unbound Review · Score 4/5 (P2s only) · 0fc1c21

  • codex (own score 4/5): The PR adds a best-effort GlitchTip copy of Sentry events, with a separate circuit breaker and a shared time budget. The reporting flow appears consistent with the stated behavior, but several new tests violate the repository's HTTP testing rule.
  • claude (own score 4/5): The PR copies every Sentry event to a self-hosted GlitchTip project on a best-effort basis. The copy has its own 3-strike failure counter, uses whatever is left of the caller's time budget, and turns itself off whenever AI_DISCOVERY_SENTRY_DSN is set. I checked the budget math against the _left_for_telemetry() callers in send_report and found no defect. The extracted _post_sentry_event keeps the old curl behaviour, and the reset and breaker-isola

findings: 0 P0 · 0 P1 · 1 P2 (top 5 P0/P1 inline) · engines: codex ✅ · claude ✅

Findings not posted inline
  • P2 tests/test_discovery_flow.py:825 Use real HTTP servers for transport tests — The new transport tests mock subprocess.run instead of exercising HTTP against a local server. This bypasses the repository's required HTTP testing approach and cannot verify the actual curl requests in those cases. (codex+claude)

rules applied: CLAUDE.md

Each event report_to_sentry posts is also posted, with the same event_id,
to the GlitchTip project. The copy has its own failure counter, so a
blocked GlitchTip host cannot switch Sentry reporting off.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@anonpran
anonpran requested a review from a team November 30, 2026 04:23

@vigneshsubbiah16 vigneshsubbiah16 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Automated Security Review (consensus)

1 finding — 0 high-confidence, 1 to triage. Reviewers: Claude (lead), Semgrep, Gitleaks.

  • [LOW] GlitchTip DSN is hardcoded with no env override 🟡 — scripts/coding_discovery_tools/utils.py:3343
    • What: _GLITCHTIP_DSN is a fixed literal. The Sentry DSN next to it can be overridden with AI_DISCOVERY_SENTRY_DSN, but this one cannot be overridden, rotated or turned off on its own.
    • Why: A DSN key is a public ingest key, not a secret, which is why Gitleaks did not flag it. But this one ships inside an agent that runs on customer endpoints. Anyone can pull it from the script and flood the self-hosted sentry.unboundsecurity.ai project 7 with fake events. That uses up the server's storage and capacity and pollutes the trial data. Rotating the key or stopping the copy means shipping a new agent release, and old agents keep posting with the old key until it is revoked on the server.
    • Fix: Read it as os.environ.get("AI_DISCOVERY_GLITCHTIP_DSN", "<default>"), the same way _SENTRY_DSN is read. Also turn on rate limits or event quotas for that project on the GlitchTip server.
    • Flagged by: Claude

🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head fe4d5a1e · 2026-11-30T04:24Z

@anonpran

Copy link
Copy Markdown
Contributor Author

/review code

Also fixes the time-budget test on Windows, where the coarse clock let the
copy through, and moves the main copy test onto real local servers.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@anonpran

Copy link
Copy Markdown
Contributor Author

/review code

@vigneshsubbiah16 vigneshsubbiah16 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Security consensus: no issues found. (reviewers: claude, semgrep, gitleaks)


🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 0fc1c218 · 2026-11-30T04:52Z

@anonpran
anonpran merged commit 80c73b1 into staging Nov 30, 2026
11 checks passed
anonpran added a commit that referenced this pull request Nov 30, 2026
…p-dual-send (#447)

Send discovery agent errors to GlitchTip as well as Sentry (WEB-6914)
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.

3 participants