Skip to content

fix(alerts): bound alert event listings and leave the entity out of their rows - #36261

Closed
manerow wants to merge 1 commit into
mainfrom
fix/alerts-bounded-listings
Closed

manerow wants to merge 1 commit into
mainfrom
fix/alerts-bounded-listings

Conversation

@manerow

@manerow manerow commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong

Eight alert event listings in EventSubscriptionResource accept a limit with no upper bound, and pass it straight to SQL as LIMIT:

Route
GET /id/{id}/listEvents
GET /id/{id}/diagnosticInfo
GET /name/{fqn}/diagnosticInfo
GET /id/{id}/failedEvents
GET /name/{fqn}/failedEvents
GET /listAllFailedEvents
GET /id/{id}/listSuccessfullySentChangeEvents
GET /name/{name}/listSuccessfullySentChangeEvents

Each row also holds a copy of the whole entity that changed, which can be as large as the asset. So one request can load an unbounded amount of data into memory, and these routes are readable by every user.

GET /v1/events already caps limit at 1000; these listings never got the same bound.

What this changes

  • Row limit. The eight limit parameters get @Max(1000), the same bound as GET /v1/events, from one constant (AlertLimits.MAX_LISTING_ROWS). A larger value is answered 400.

  • No embedded entity. The listing queries leave the embedded entity out of each row in SQL, so it is never read from the database:

    • JSON_REMOVE on MySQL;
    • the - / #- operators on Postgres;
    • delivered rows drop $.entity, failed rows drop $.changeEvent.entity.

    Every other field of the event is unchanged.

  • Not changed: listUnprocessedEvents, used by diagnosticInfo, keeps the entity. Those rows are evaluated against the alert's filters, which read it. Its limit is still capped.

What users see

Nothing in the UI: it pages these listings by 15, 25 or 50 and never reads the embedded entity. It shows the event's own fields and changeDescription.

API clients that ask for more than 1000 rows now get a 400, and listed events no longer carry entity.

Tests

  • AlertListingLimitsIT (new; both tests failed on main before this change):
    • all eight routes answer 400 to limit=1001;
    • delivered, failed and combined listings return rows without entity, with every field the alert page reads.
  • Passing on MySQL and Postgres: AlertListingLimitsIT, AlertTickOutcomesIT, DispatchScenariosIT, EventSubscriptionBatchUpsertIT and EventSubscriptionResourceIT (283 tests on each database).

A backport to 2.0 follows in a separate PR.

RetriggerView in GreptileConfidence Score: 4/5

The PR appears safe to merge, with a non-blocking cleanup issue in the new tests.

Findings

  1. P2 Test alerts stay active ▶

Summary

Caps eight alert event listings at 1000 rows and removes embedded entity from delivered and failed listing results in SQL.

  • Alert listings reject requests for more than 1,000 rows.
  • Listed alert events leave the changed asset out of each row.

Intent acknowledged by manerow in the PR description: listed events no longer include entity, and requests above 1000 rows return 400.

Reviews (1) · Last reviewed commit: "fix(alerts): bound alert event listings ..." · Reviewed by Greptile

@manerow
manerow requested a review from a team as a code owner October 26, 2026 14:03
@manerow manerow added the safe to test Add this label to run secure Github workflows on PRs label Oct 26, 2026
@manerow
manerow requested a review from IceS2 October 26, 2026 14:03
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

Comment on lines +1087 to +1098
// The listings below answer each event without the entity it carries: the alert pages read
// only the event's own fields, and the entity is as large as the asset that changed.
@ConnectionAwareSqlQuery(
value =
"SELECT JSON_REMOVE(json, '$.changeEvent.entity') AS json, source FROM consumers_dlq "
+ "WHERE id = :id ORDER BY timestamp DESC LIMIT :limit OFFSET :paginationOffset",
connectionType = MYSQL)
@ConnectionAwareSqlQuery(
value =
"SELECT json #- '{changeEvent,entity}' AS json, source FROM consumers_dlq "
+ "WHERE id = :id ORDER BY timestamp DESC LIMIT :limit OFFSET :paginationOffset",
connectionType = POSTGRES)

@gitar-bot gitar-bot Bot Oct 26, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Quality: Dropping entity from alert listings is a REST contract with no record

The PR changes what the alert event listings return. /failedEvents, /listAllFailedEvents, /listSuccessfullySentChangeEvents and /listEvents now strip $.entity / $.changeEvent.entity in SQL, while diagnosticInfo's listUnprocessedEvents keeps it on purpose. Every API client, SDK and UI has to agree with this response shape. The rule exists only in the PR description and in two DAO comments, and nothing in docs/decisions/ records it. The repo squash-merges, so the description's line "listUnprocessedEvents ... keeps the entity. Those rows are evaluated against the alert's filters" will be lost. Without a record, someone could later put entity back in these listings (bringing back the unbounded read), or drop it from listUnprocessedEvents (breaking filter evaluation), and no record would object.

Add a record that asserts: "Alert event listings (delivered, failed and combined) return change events without the embedded entity, and their limit is capped at AlertLimits.MAX_LISTING_ROWS (1000, the same as GET /v1/events). Only listUnprocessedEvents returns the entity, because alert filters read it." Cite it as ADR:<date>-<slug> beside the DAO comments and AlertLimits.

Add docs/decisions/2026-10-xx-alert-event-listings-omit-the-entity-and-cap-rows.md and cite it at the DAO comments:

// ADR:2026-10-xx-alert-event-listings-omit-the-entity-and-cap-rows
// The listings below answer each event without the entity it carries: the alert pages read
// only the event's own fields, and the entity is as large as the asset that changed.

Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Code Review ⚠️ Changes requested 0 closed / 1 findings

🔴 High risk · Removing embedded entities and rejecting limits above 1000 changes alert-listing responses, which could break clients relying on prior payloads or pagination.

Bounds the eight alert event listing limit parameters at 1000 via AlertLimits.MAX_LISTING_ROWS and strips the embedded entity from delivered and failed rows in SQL, leaving listUnprocessedEvents unchanged. Changes requested: the removal of entity from these listings is a REST contract change with no decision record, so an ADR should be added to docs/decisions/ and cited beside the DAO comments and AlertLimits.

⚠️ Quality: Dropping entity from alert listings is a REST contract with no record

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AccessControlDAOs.java:1087-1098 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AccessControlDAOs.java:1163-1167 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AccessControlDAOs.java:1177-1180 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EventSubscriptionDAOs.java:341-354 📄 openmetadata-service/src/main/java/org/openmetadata/service/alerting/AlertLimits.java:3-7

The PR changes what the alert event listings return. /failedEvents, /listAllFailedEvents, /listSuccessfullySentChangeEvents and /listEvents now strip $.entity / $.changeEvent.entity in SQL, while diagnosticInfo's listUnprocessedEvents keeps it on purpose. Every API client, SDK and UI has to agree with this response shape. The rule exists only in the PR description and in two DAO comments, and nothing in docs/decisions/ records it. The repo squash-merges, so the description's line "listUnprocessedEvents ... keeps the entity. Those rows are evaluated against the alert's filters" will be lost. Without a record, someone could later put entity back in these listings (bringing back the unbounded read), or drop it from listUnprocessedEvents (breaking filter evaluation), and no record would object.

Add a record that asserts: "Alert event listings (delivered, failed and combined) return change events without the embedded entity, and their limit is capped at AlertLimits.MAX_LISTING_ROWS (1000, the same as GET /v1/events). Only listUnprocessedEvents returns the entity, because alert filters read it." Cite it as ADR:<date>-<slug> beside the DAO comments and AlertLimits.

Add docs/decisions/2026-10-xx-alert-event-listings-omit-the-entity-and-cap-rows.md and cite it at the DAO comments
// ADR:2026-10-xx-alert-event-listings-omit-the-entity-and-cap-rows
// The listings below answer each event without the entity it carries: the alert pages read
// only the event's own fields, and the entity is as large as the asset that changed.
🤖 Prompt for agents
Code Review: Bounds the eight alert event listing `limit` parameters at 1000 via `AlertLimits.MAX_LISTING_ROWS` and strips the embedded `entity` from delivered and failed rows in SQL, leaving `listUnprocessedEvents` unchanged. Changes requested: the removal of `entity` from these listings is a REST contract change with no decision record, so an ADR should be added to `docs/decisions/` and cited beside the DAO comments and `AlertLimits`.

1. ⚠️ Quality: Dropping `entity` from alert listings is a REST contract with no record
   Files: openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AccessControlDAOs.java:1087-1098, openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AccessControlDAOs.java:1163-1167, openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AccessControlDAOs.java:1177-1180, openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EventSubscriptionDAOs.java:341-354, openmetadata-service/src/main/java/org/openmetadata/service/alerting/AlertLimits.java:3-7

   The PR changes what the alert event listings return. `/failedEvents`, `/listAllFailedEvents`, `/listSuccessfullySentChangeEvents` and `/listEvents` now strip `$.entity` / `$.changeEvent.entity` in SQL, while `diagnosticInfo`'s `listUnprocessedEvents` keeps it on purpose. Every API client, SDK and UI has to agree with this response shape. The rule exists only in the PR description and in two DAO comments, and nothing in `docs/decisions/` records it. The repo squash-merges, so the description's line "`listUnprocessedEvents` ... keeps the entity. Those rows are evaluated against the alert's filters" will be lost. Without a record, someone could later put `entity` back in these listings (bringing back the unbounded read), or drop it from `listUnprocessedEvents` (breaking filter evaluation), and no record would object.
   
   Add a record that asserts: "Alert event listings (delivered, failed and combined) return change events without the embedded `entity`, and their `limit` is capped at `AlertLimits.MAX_LISTING_ROWS` (1000, the same as `GET /v1/events`). Only `listUnprocessedEvents` returns the entity, because alert filters read it." Cite it as `ADR:<date>-<slug>` beside the DAO comments and `AlertLimits`.

   Fix (Add docs/decisions/2026-10-xx-alert-event-listings-omit-the-entity-and-cap-rows.md and cite it at the DAO comments):
   // ADR:2026-10-xx-alert-event-listings-omit-the-entity-and-cap-rows
   // The listings below answer each event without the entity it carries: the alert pages read
   // only the event's own fields, and the entity is as large as the asset that changed.

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

Comment on lines +46 to +47
EventSubscription delivered = webhookAlert(ns, "listing_delivered", receiver);
EventSubscription failed = webhookAlert(ns, "listing_failed", receiver, "/failing");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Test alerts stay active

Both tests leave enabled alerts behind after RecordingReceiver closes. AlertFixtures.tableAlert does not register cleanup, and TestNamespaceExtension only deletes tracked roots. Repeated runs leave alert rows and scheduled jobs pointing at stopped receivers.

Delete each created subscription in a finally block before closing its receiver, including when an assertion fails.

@sonarqubecloud

Copy link
Copy Markdown

@manerow

manerow commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Folded into PR #36279, which now carries all the alerting bounds in one change.

@manerow manerow closed this Oct 26, 2026
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.

1 participant