Repository navigation
fix(web): crashes on Automation settings, /alerts and repeated Connect clicks #2086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
packages/db/drizzle/20261101232654_drop_hazel_oauth_destinations/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| -- Retire the `hazel-oauth` alert destination (#2022 removed its transport and type), as | ||
| -- 20260924110710_drop_legacy_slack did for `slack-bot`. Rows of a type the code no longer | ||
| -- decodes crashed the dashboard's alert and automation pages. Every reference goes with them: | ||
| -- a rule left with no destination is disabled, since an enabled rule must name one; an | ||
| -- escalation severity left with none is dropped; the error policy may name none. | ||
| UPDATE "alert_rules" AS rules | ||
|
Makisuo marked this conversation as resolved.
Resolved
|
||
| SET | ||
| "destination_ids_json" = COALESCE( | ||
| ( | ||
| SELECT jsonb_agg(destination_id) | ||
| FROM jsonb_array_elements_text(CASE WHEN jsonb_typeof(rules."destination_ids_json") = 'array' THEN rules."destination_ids_json" ELSE '[]'::jsonb END) AS ids(destination_id) | ||
| WHERE destination_id NOT IN (SELECT "id" FROM "alert_destinations" WHERE "type" = 'hazel-oauth') | ||
| ), | ||
| '[]'::jsonb | ||
| ), | ||
| "enabled" = rules."enabled" AND EXISTS ( | ||
| SELECT 1 | ||
| FROM jsonb_array_elements_text(CASE WHEN jsonb_typeof(rules."destination_ids_json") = 'array' THEN rules."destination_ids_json" ELSE '[]'::jsonb END) AS ids(destination_id) | ||
| WHERE destination_id NOT IN (SELECT "id" FROM "alert_destinations" WHERE "type" = 'hazel-oauth') | ||
| ) | ||
| WHERE jsonb_typeof(rules."destination_ids_json") = 'array' | ||
| AND EXISTS ( | ||
| SELECT 1 | ||
| FROM jsonb_array_elements_text(CASE WHEN jsonb_typeof(rules."destination_ids_json") = 'array' THEN rules."destination_ids_json" ELSE '[]'::jsonb END) AS ids(destination_id) | ||
| JOIN "alert_destinations" AS destinations ON destinations."id" = destination_id | ||
| WHERE destinations."type" = 'hazel-oauth' | ||
| );--> statement-breakpoint | ||
| -- Each severity tier names its own destinations (the column above is their union); a tier | ||
| -- keeps its place even when it is left with none. | ||
| UPDATE "alert_rules" AS rules | ||
| SET "thresholds_json" = ( | ||
| SELECT jsonb_agg( | ||
| CASE | ||
| WHEN jsonb_typeof(tier -> 'destinationIds') = 'array' THEN jsonb_set( | ||
| tier, | ||
| '{destinationIds}', | ||
| COALESCE( | ||
| ( | ||
| SELECT jsonb_agg(destination_id) | ||
| FROM jsonb_array_elements_text(CASE WHEN jsonb_typeof(tier -> 'destinationIds') = 'array' THEN tier -> 'destinationIds' ELSE '[]'::jsonb END) AS ids(destination_id) | ||
| WHERE destination_id NOT IN (SELECT "id" FROM "alert_destinations" WHERE "type" = 'hazel-oauth') | ||
| ), | ||
| '[]'::jsonb | ||
| ) | ||
| ) | ||
| ELSE tier | ||
| END | ||
| ORDER BY tiers.position | ||
| ) | ||
| FROM jsonb_array_elements(CASE WHEN jsonb_typeof(rules."thresholds_json") = 'array' THEN rules."thresholds_json" ELSE '[]'::jsonb END) WITH ORDINALITY AS tiers(tier, position) | ||
| ) | ||
| WHERE jsonb_typeof(rules."thresholds_json") = 'array' | ||
| AND jsonb_array_length(CASE WHEN jsonb_typeof(rules."thresholds_json") = 'array' THEN rules."thresholds_json" ELSE '[]'::jsonb END) > 0 | ||
| AND EXISTS ( | ||
| SELECT 1 | ||
| FROM jsonb_array_elements(CASE WHEN jsonb_typeof(rules."thresholds_json") = 'array' THEN rules."thresholds_json" ELSE '[]'::jsonb END) AS tiers(tier) | ||
| CROSS JOIN LATERAL jsonb_array_elements_text(CASE WHEN jsonb_typeof(tier -> 'destinationIds') = 'array' THEN tier -> 'destinationIds' ELSE '[]'::jsonb END) AS ids(destination_id) | ||
| JOIN "alert_destinations" AS destinations ON destinations."id" = ids.destination_id | ||
| WHERE destinations."type" = 'hazel-oauth' | ||
| );--> statement-breakpoint | ||
| UPDATE "error_notification_policies" AS policies | ||
| SET "destination_ids_json" = COALESCE( | ||
| ( | ||
| SELECT jsonb_agg(destination_id) | ||
| FROM jsonb_array_elements_text(CASE WHEN jsonb_typeof(policies."destination_ids_json") = 'array' THEN policies."destination_ids_json" ELSE '[]'::jsonb END) AS ids(destination_id) | ||
| WHERE destination_id NOT IN (SELECT "id" FROM "alert_destinations" WHERE "type" = 'hazel-oauth') | ||
| ), | ||
| '[]'::jsonb | ||
| ) | ||
| WHERE jsonb_typeof(policies."destination_ids_json") = 'array' | ||
| AND EXISTS ( | ||
| SELECT 1 | ||
| FROM jsonb_array_elements_text(CASE WHEN jsonb_typeof(policies."destination_ids_json") = 'array' THEN policies."destination_ids_json" ELSE '[]'::jsonb END) AS ids(destination_id) | ||
| JOIN "alert_destinations" AS destinations ON destinations."id" = destination_id | ||
| WHERE destinations."type" = 'hazel-oauth' | ||
| );--> statement-breakpoint | ||
| UPDATE "issue_escalation_policies" AS policies | ||
| SET "rules_json" = COALESCE( | ||
| ( | ||
| SELECT jsonb_agg(jsonb_set(rule, '{destinationIds}', kept.ids) ORDER BY rules.position) | ||
| FROM jsonb_array_elements(CASE WHEN jsonb_typeof(policies."rules_json") = 'array' THEN policies."rules_json" ELSE '[]'::jsonb END) WITH ORDINALITY AS rules(rule, position) | ||
| CROSS JOIN LATERAL ( | ||
| SELECT COALESCE(jsonb_agg(destination_id), '[]'::jsonb) AS ids | ||
| FROM jsonb_array_elements_text(CASE WHEN jsonb_typeof(rule -> 'destinationIds') = 'array' THEN rule -> 'destinationIds' ELSE '[]'::jsonb END) AS ids(destination_id) | ||
| WHERE destination_id NOT IN (SELECT "id" FROM "alert_destinations" WHERE "type" = 'hazel-oauth') | ||
| ) AS kept | ||
| WHERE jsonb_array_length(kept.ids) > 0 | ||
| ), | ||
| '[]'::jsonb | ||
| ) | ||
| WHERE jsonb_typeof(policies."rules_json") = 'array' | ||
| AND NOT EXISTS ( | ||
| SELECT 1 | ||
| FROM jsonb_array_elements(CASE WHEN jsonb_typeof(policies."rules_json") = 'array' THEN policies."rules_json" ELSE '[]'::jsonb END) AS rules(rule) | ||
| WHERE jsonb_typeof(rule -> 'destinationIds') IS DISTINCT FROM 'array' | ||
| ) | ||
| AND EXISTS ( | ||
| SELECT 1 | ||
| FROM jsonb_array_elements(CASE WHEN jsonb_typeof(policies."rules_json") = 'array' THEN policies."rules_json" ELSE '[]'::jsonb END) AS rules(rule) | ||
| CROSS JOIN LATERAL jsonb_array_elements_text(CASE WHEN jsonb_typeof(rule -> 'destinationIds') = 'array' THEN rule -> 'destinationIds' ELSE '[]'::jsonb END) AS ids(destination_id) | ||
| JOIN "alert_destinations" AS destinations ON destinations."id" = ids.destination_id | ||
| WHERE destinations."type" = 'hazel-oauth' | ||
| );--> statement-breakpoint | ||
| DELETE FROM "error_notification_deliveries" | ||
| WHERE "destination_id" IN (SELECT "id" FROM "alert_destinations" WHERE "type" = 'hazel-oauth');--> statement-breakpoint | ||
| DELETE FROM "alert_delivery_events" | ||
| WHERE "destination_id" IN (SELECT "id" FROM "alert_destinations" WHERE "type" = 'hazel-oauth');--> statement-breakpoint | ||
| DELETE FROM "alert_destinations" | ||
| WHERE "type" = 'hazel-oauth'; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.