add alert query mode metadata#1707
Conversation
persist queryType for alerts: builder, code, or promql defaults old alerts to builder accepts legacy queryType=sql as code reserves old creationType keys treats builder/code as SQL modes for auth and dataset resolution.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds ChangesAlert query type and contracts
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant AlertRequest
participant AlertConfig
participant AlertAuthorization
participant DatasetAccess
Client->>AlertRequest: submit queryType and datasets
AlertRequest->>AlertConfig: resolve or validate datasets
Client->>AlertAuthorization: access alert
AlertAuthorization->>AlertConfig: inspect query_type
AlertAuthorization->>DatasetAccess: authorize PromQL dataset
DatasetAccess-->>AlertAuthorization: allow or deny
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/alerts/alert_types.rs`:
- Around line 94-97: The PromQL guard in validate() is too late because
Alerts::load still enqueues unsupported ThresholdAlert entries before
validation. Update the load/scheduling path so unsupported
AlertQueryType::Promql alerts are filtered out or marked disabled before
creating an AlertTask::Create, using the existing validate() /
AlertError::NotPresentInOSS logic as the source of truth. Make sure both
occurrences in alert_types.rs are covered so OSS never schedules PromQL alerts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: bd53268e-dd27-4454-a46a-b83b6e7fb28d
📒 Files selected for processing (8)
src/alerts/alert_enums.rssrc/alerts/alert_structs.rssrc/alerts/alert_traits.rssrc/alerts/alert_types.rssrc/alerts/mod.rssrc/handlers/http/alerts.rssrc/lib.rssrc/metastore/metastore_traits.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/alerts/mod.rs`:
- Around line 153-162: The OSS alert loading path is aborting on unsupported
alert types because `load()` propagates errors from `alert_from_config_oss`, so
a single anomaly or forecast config stops later alerts from being loaded. Update
the alert-loading logic in `load()` to mirror the unschedulable-alert handling
below by skipping `AlertError::NotPresentInOSS` cases instead of returning
early, while keeping supported `Threshold` alerts loaded normally through
`alert_from_config_oss`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
persist queryType for alerts: builder, code, or promql
defaults old alerts to builder
accepts legacy queryType=sql as code
reserves old creationType keys
treats builder/code as SQL modes for auth and dataset resolution
Summary by CodeRabbit
New Features
Bug Fixes
sqlquery type value.