feat(observability): add alert rule toggle APIs - #14269
ThisIsMani wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d470130cb7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Ok(Self { | ||
| rule_id, | ||
| is_enabled: request.is_enabled, | ||
| updated_by: request.updated_by, |
There was a problem hiding this comment.
Reject blank updater identities
When a caller sends "updated_by": " ", this value is persisted and later returned as the audit identity, leaving the toggle change unattributed. The sibling threshold API explicitly rejects blank updated_by values, so validate this field with trim().is_empty() before constructing the row.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in the latest tree: whitespace-only updated_by is rejected before persistence, with route coverage confirming an invalid request does not overwrite stored state.
There was a problem hiding this comment.
Fixed in the latest tree: blank or whitespace-only updated_by values are rejected before persistence, with route and domain coverage.
d470130 to
8af6c22
Compare
4dfa5d9 to
e9d5da8
Compare
8af6c22 to
5af5395
Compare
Summary
This is the stacked Rule enable/disable toggles port for the observability plane. It moves only the named domain's mutable-state list/set operations behind authenticated typed APIs and preserves rule identity, disabled-rule behavior, and portal-compatible set responses.
Depends on base PR #14268 (
feat/observability-alert-blacklist), which is also the target branch for this PR.APIs
GET /alerts/rule-togglesPUT /alerts/rule-toggles/{rule_id}X-Internal-Api-Keyauthentication and typed JSON models.{ "ok", "id", "is_enabled" }.Schema and persistence
alert_rule_togglesPostgreSQL migration.rule_idas the natural identity.Tests
cargo fmt --all -- --checkcargo check -p observabilitycargo test -p observability --test rule_toggles(4 passed; 1 database test ignored in the no-database run)cargo test -p observability --test blacklist --test thresholds(12 passed; 2 database tests ignored)cargo test -p observability rule_id_is_trimmed_and_blank_is_rejecteddiesel migration run --locked-schemaagainst a temporary local PostgreSQL databasediesel migration redo --locked-schema --allagainst a temporary local PostgreSQL databaseOBSERVABILITY_TEST_DATABASE_URL=... cargo test -p observability --test rule_toggles postgres_repository_replaces_and_lists_toggles -- --ignoredgit diff --checkAnalytical/business reads and users are unchanged. No analytics or user endpoints are added or moved.