Skip to content

fix(alerts): destination ids belong to the server - #36791

Merged
manerow merged 3 commits into
mainfrom
fix/alert-destination-ids-server-owned
Nov 3, 2026
Merged

manerow merged 3 commits into
mainfrom
fix/alert-destination-ids-server-owned

Conversation

@manerow

@manerow manerow commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #36790

A destination's id names one destination of one alert, but the server kept whatever id a request sent. An API client that built an alert from another alert's JSON, or sent the same id twice, could store two destinations with the same id. Code that finds a destination by its id, such as restoring its stored values on save or a test send, could then pick the wrong one.

The server now owns destination ids:

  • Create: every destination of a new alert gets a fresh id, whatever the request says (DestinationIds.assignNew, on single and bulk create).
  • Update (PUT and PATCH): an id counts only if this alert stores it, and only once. Any other id is ignored, and that destination is matched by position like one sent without an id (DestinationIds.forgetIdsNotIssuedHere, before any id-based matching). Ignoring keeps an existing client pattern working: sending the same create request again as a PUT keeps the alert's ids.
  • Existing data: a 2.1.0 data step gives a new id to any stored destination whose id is missing or already used, alert by alert (DestinationIdMigration).

With ids unique, the test-send lookup no longer needs the "more than one destination holds this id" refusal added in PR #36147, so it is removed with its test.

Type of change:

  • Bug fix

Tests:

  • Unit: DestinationIdsTest, DestinationIdMigrationTest, plus every org.openmetadata.service.alerting unit test (707 pass).
  • Integration: EventSubscriptionResourceIT#test_destinationIdsAreTheServers (create ignores sent ids; a repeated PUT, an unknown id and a repeated id keep the stored ids; an added destination gets its own). EventSubscriptionResourceIT, AlertStateIT, TemplateTestSendIT, DispatchScenariosIT, AlertReconcilerIT, SlowEndpointIT, MetricResourceIT pass locally on Postgres. One check in test_destinationSecretsTheServerAloneWrites_400 now adds a masked destination instead of renaming one, since a foreign id is ignored rather than refused.

UI screen recording:

Not applicable: no UI change.

Checklist:

@manerow
manerow requested a review from a team as a code owner November 1, 2026 14:12
@manerow
manerow requested a review from TeddyCr November 1, 2026 14:13
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Nov 1, 2026
@gitar-bot

gitar-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 closed / 1 findings

🔴 High risk · The 2.1.0 migration rewrites missing or duplicate destination IDs; incorrect reassignment could make alert updates or test sends target the wrong destination.

Server now owns destination ids on alert create, PUT, and PATCH, assigning fresh ids on create and ignoring client ids that the alert does not store or that repeat, with a migration that reissues missing or duplicate stored ids. The secrets ADR was amended to cover the new matching rule, addressing the missing ADR record finding, and a cross-alert test was added for copied ids. No open issues found.

✅ 1 closed
✅ Quality: Server-owned destination id rule changes the secrets ADR, no record

📄 openmetadata-service/src/main/java/org/openmetadata/service/alerting/channel/DestinationIds.java:27-41 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EventSubscriptionRepository.java:243-248 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EventSubscriptionRepository.java:321 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EventSubscriptionRepository.java:343 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EventSubscriptionRepository.java:296-302
This PR changes a REST contract that API clients and the UI have to agree with, and it records nothing. A create now throws away every destination id the request sends. A PUT or PATCH keeps an id only when the alert already stores it, and only for its first use. Any other id is silently ignored, and that destination is matched by position. That means requests the server used to refuse are now accepted: the PR rewrites one check in test_destinationSecretsTheServerAloneWrites_400 because 'a foreign id is ignored rather than refused'.

The Accepted record docs/decisions/2026-10-23-alert-destination-secrets-are-encrypted-masked-and-restored.md says a mask is restored 'by destination id, or, for a PUT that carries no ids, by position'. With this PR, position matching also applies to PATCH and to any destination whose id is foreign or repeated. Separately, findDestination dropped its ambiguity refusal. It is now only correct if every save path and the 2.1.0 data step keep ids unique across all alerts, and no single file shows that.

The rule comes from the PR description, which is lost on squash-merge: 'The server now owns destination ids… an id counts only if this alert stores it, and only once. Any other id is ignored, and that destination is matched by position.' Please add a decision record (or a new revision of the secrets ADR) that states: "A destination's id is issued by the server and names one destination of one alert. A create assigns every destination a fresh id whatever the request sends. An update honours an id only if the alert stores it, and only once; any other id is ignored and its destination is matched by position as one sent without an id. Ids are therefore unique across alerts, so a test send resolves a destination by its id alone." List DestinationIdsTest and EventSubscriptionResourceIT#test_destinationIdsAreTheServers as its Guard.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@manerow
manerow merged commit 3e99b48 into main Nov 3, 2026
64 of 67 checks passed
@manerow
manerow deleted the fix/alert-destination-ids-server-owned branch November 3, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alert destination ids can be set by API clients and shared between destinations

2 participants