Repository navigation
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
| public static void removeAppEventSubscriptions( | ||
| Handle handle, ConnectionType connectionType, CollectionDAO dao) { | ||
| List<String> appAlerts = | ||
| bindLinks(handle.createQuery("SELECT DISTINCT toId" + APP_ALERT_LINKS)) | ||
| .mapTo(String.class) | ||
| .list(); | ||
| appAlerts.forEach(id -> disable(dao.eventSubscriptionDAO(), UUID.fromString(id))); | ||
| bindLinks(handle.createUpdate("DELETE" + APP_ALERT_LINKS)).execute(); | ||
| removeFieldSql(connectionType).forEach(sql -> handle.createUpdate(sql).execute()); | ||
| StoredChangeEventCleanup.removeEntityFields( | ||
| handle, | ||
| connectionType, | ||
| Set.of(Entity.APPLICATION, Entity.APP_MARKET_PLACE_DEF), | ||
| Set.of(FIELD)); |
There was a problem hiding this comment.
Migration lacks database tests
No automated test runs this migration. StoredChangeEventCleanupTest only checks JSON rewriting, and AppEventSubscriptionRemovalIT checks API behavior after the upgrade. Neither covers alert disabling, relationship removal, database-specific SQL, or paging through stored events.
Add MySQL and Postgres tests that seed linked and unrelated alerts, app versions, and more than 500 stored events. Run the migration twice and check the saved rows. The manual upgrade check described in the PR cannot catch later regressions.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| // The 2.0.7 post-data SQL disables these alerts; their names go to the log first. | ||
| AppCreatedAlerts.logForReview(handle); |
There was a problem hiding this comment.
⚠️ Bug: Alerts disabled without being logged when 2.0.7 is reprocessed
MigrationWorkflow.shouldRunDataMigration (MigrationWorkflow.java:508-514) skips the Java data migration for a reprocessed version from an earlier release train. postDataMigrationSQLScript.sql still runs as appended SQL, because hasPendingWork counts it as new statements. On a database already at 2.1.0 (the 2.1.0 migration dir exists), upgrading reprocesses 2.0.7, so the SQL disables every app-created alert and deletes its entity_relationship rows, but AppCreatedAlerts.logForReview never runs. No names get logged, and once the relations are gone the alerts can no longer be identified. That breaks the stated guarantee that disabled alerts are logged by name so an admin can review them. One fix is to have the SQL leave a durable marker on each alert it disables (for example $.disabledByAppRemoval = true, or a row in a review table) and have the log query read that marker. The marker query can then also run from the 2.1.0 migration or another step that always runs. Another option is to move the disable/untie into the same Java step as the log, so the two always run or skip together.
Mark the disabled alerts in SQL so the log query can still find them after the relations are deleted (MySQL shown; Postgres uses jsonb_set with '{disabledByAppRemoval}').:
UPDATE event_subscription_entity
SET json = JSON_SET(json, '$.enabled', CAST('false' AS JSON), '$.disabledByAppRemoval', CAST('true' AS JSON))
WHERE id IN (SELECT toId FROM entity_relationship WHERE fromEntity = 'app' AND toEntity = 'eventsubscription' AND relation = 0);
Was this helpful? React with 👍 / 👎
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
|
Replaced by PR #36251, which combines this change with its companion fix in one PR. |
|
|



Describe your changes:
An app's marketplace definition could list alerts (
eventSubscriptions). Every install created them without checking that the caller may create alerts: schedule, deploy, restore, a PATCH of the app, and the install at startup.Anyone who can edit a definition, including a user who becomes the owner of one that has none, could add an alert with a webhook of their choice. The next install created it, and the server sent every later change event to that URL, although
POST /v1/events/subscriptionsrefuses that user.No app we ship (OpenMetadata or Collate) has ever listed alerts in its definition, and nothing else reads the field. So this PR removes the feature instead of adding a permission check to each install path:
eventSubscriptionsis removed fromapp.json,appMarketPlaceDefinition.jsonandcreateAppMarketPlaceDefinitionReq.json, plus the install and cleanup code that used it. A request that still sends the field gets a 400.classNameon alerts (custom consumers), from the same original change, is used and stays.Removing the field moved three shared generated enums, so they are now pinned to
org.openmetadata.schema.entity.events.{AlertType,Effect,PrefixCondition}. Most files only change an import.Migration (2.0.7)
Plain SQL in the 2.0.7
postDataMigrationSQLScript.sql, with fixed names, so later code cannot change it. SQL in 2.0.7 also runs on a database already at a 2.1.0 build, which skips 2.0.7 Java steps:app);eventSubscriptionsleaves stored apps, definitions, versions and change events.Not possible in SQL: logging the alerts it disables.
AppCreatedAlerts, the only Java, logs their names first.Type of change:
Tests:
Unit tests
Backend integration tests
AppEventSubscriptionRemovalIT:mainand pass here, on MySQL and Postgres.Also checked by upgrading a real 2.0.6 database (MySQL and Postgres) through
migrate: the same result as the earlier Java version, row for row; a second run changes nothing; a database already at 2.1.0 is cleaned too.Ingestion integration tests
Playwright (UI) tests
UI screen recording / screenshots:
Not applicable. Only generated UI types change.
Checklist:


Confidence Score: 5/5
The PR appears safe to merge, with the earlier non-blocking request for database migration tests still open.Findings
Summary
Removes alerts from app definitions and stops app installs and deletions from creating or deleting alerts.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Run 2.0.7 migration] --> B[Log app-created alert names] B --> C[Disable linked alerts] C --> D[Remove app-to-alert links] D --> E[Remove eventSubscriptions from stored apps and events]Reviews (4) · Last reviewed commit: "fix: run the app alert cleanup as plain ..." · Reviewed by Greptile