Repository navigation
fix(alerts): previewing or testing a rule needs read scopes for its telemetry - #2507
Conversation
…elemetry A rule preview or test runs the rule's query and returns what it measured, so a scoped API key must also be able to read the telemetry that query reads.
This comment has been minimized.
This comment has been minimized.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 10 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Every branch of the signal-to-family mapping is unit tested, and a logs builder preview is refused over HTTP to a key that reads only traces.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…le test gate Uptime and SLO rules are refused before any query runs, so asking for read scopes first only hid that answer. The rule test endpoint's scope refusal now has an HTTP test of its own.
|
Fixed F2 and F3 in 4ca4b35: uptime and SLO rules now need no telemetry scopes (they are refused before any query runs), and |
Maple review🟢 Confidence 10/10 · safe to merge. A scope tightening whose mapping is unit-tested per branch and pinned over HTTP; the managed-signal and MCP paths are ruled out by reading them. Gates the two v2 alert routes that run a rule's query and return what it measured behind the telemetry read scopes that query needs. The signal-to-family mapping is unit-tested branch by branch, refusals are pinned over HTTP without touching the warehouse, and the earlier findings on managed signals and the
Fixed since the last review
|
What
POST /v2/alerts/rules/previewandPOST /v2/alerts/rules/testrun the rule's query and return the values it measured. Scoped API keys now also need read access to the telemetry that query reads:error_rate,p95_latency,p99_latency,apdex,throughputtraces:readbuilder_querytraces:read,logs:readormetrics:read); any other source needs all threeraw_querytraces:read,logs:readandmetrics:readanomalyWithout them the request is refused with 403 before any query runs. Unscoped keys, OAuth tokens and dashboard sessions are unaffected. The raw SQL preview still also requires
alerts:write.The endpoint descriptions (and the generated iOS OpenAPI spec) document the new requirement.
Compatibility
A scoped key with only
alerts:*scopes that calls preview or test now gets a 403. Adding the telemetry read scopes restores it.Not in this PR
Creating or updating a rule with
alerts:writeand then reading its check history still returns observed values. Gating rule creation on telemetry scopes would break alerts-only keys used for config-as-code, so that is left for a separate decision.Tests
apps/api/src/routes/v2/alerts.http.test.ts: an alerts-only key is refused a structured preview without touching the warehouse; a raw SQL preview missing one family is refused; existing raw SQL preview tests now use keys that hold the telemetry scopes.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.