Skip to content

fix: apps no longer create alerts from their definition, and user credentials stay out of change events - #36251

Merged
manerow merged 16 commits into
mainfrom
fix/qr7d-app-alerts-and-user-secrets
Oct 31, 2026
Merged

manerow merged 16 commits into
mainfrom
fix/qr7d-app-alerts-and-user-secrets

Conversation

@manerow

@manerow manerow commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Five commits; review commit by commit.

Apps used alerts (event subscriptions) in two ways:

  • A. An app's own code creates the alerts it needs and records them with AppRepository.addEventSubscription (Collate's Reverse Metadata app on 2.0). This stays.
  • B. Installing an app created every alert listed in its marketplace definition, with no permission check. No shipped app uses it; it is removed.

1. Apps no longer create alerts from their marketplace definition. eventSubscriptions leaves both definition schemas and the install code (400 if sent). app.json keeps it (pattern A). Three generated enums are pinned to org.openmetadata.schema.entity.events, so most files only change an import.

2. Only the server records the alerts an app creates. App.eventSubscriptions is filled on read from the app→alert CONTAINS relationship, never stored, and cannot be patched.

3. Credentials stay out of change events and version history. "mask": true on the user's authenticationMechanism. ChangeEventDAO.insert and insertBatch mask every event (ChangeEventMasking).

4. Every entity version is written by one method. EntityRepository.storeVersions writes all versions and leaves out one list of fields: the ones the schema masks as a whole, plus the ones a repository adds through getFieldsHiddenFromHistory. Bulk updates and the data product detach used to skip it; the App and OntologyConcept overrides become hidden-field lists. VersionHistoryArchitectureTest fails on any other method that writes a version.

5. The bot token in server connections is masked, and a test checks every secret field. The mask on OpenMetadataConnection.securityConfig sat next to a $ref, where the generator drops it; it now sits on the referenced schema. SecretFieldsAreMaskedTest fails on a mask next to a $ref, and on a password field reachable from an entity that is not masked.

Migration (2.1.0, plain SQL)

In the unreleased 2.1.0 folder:

  • Alerts pattern B created are disabled and unlinked. Alerts an app's code created keep their consumer and link, which Collate's 2.1 upgrade relies on.
  • eventSubscriptions and user authenticationMechanism leave stored rows, versions and events.

Decision records: 2026-10-26-an-apps-alerts-come-from-its-code and 2026-10-26-masked-fields-stay-out-of-change-events-and-version-history.

Collate follow-up

Collate PR #7906 updates five files for the moved enums and must land with this one.

Type of change:

  • Bug fix

Tests:

Unit tests

  • VersionHistoryArchitectureTest, SecretFieldsAreMaskedTest, AppRepositoryEventSubscriptionsTest, ChangeEventMaskingTest, MaskedFieldsTest.

Backend integration tests

  • AppEventSubscriptionRemovalIT: a definition cannot carry alerts and an install creates none; an app's alert list cannot be patched; deleting an app leaves another user's alert alone.
  • UserSecretsIT: no token in bot events, versions or history.
  • Version writers: entity history, bulk, CSV import, data product detach, apps and ontology concept ITs.

Upgrade run twice on seeded 2.0.6 MySQL and Postgres.

Replaces PR #36236 and PR #36237.

Ingestion integration tests

  • Not applicable.

Playwright (UI) tests

  • Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have added tests (unit / integration) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

RetriggerView in GreptileConfidence Score: 4/5

The existing schema-loading rule violation must be fixed before merging; the latest JSON key reordering adds no new blocker.

Findings

  1. P2 Failed schema reads disappear ▶

Summary

Removes alerts from app marketplace definitions and keeps app-created alerts in relationships.

  • App alerts come from app code, not marketplace definitions.
  • Stored events and version history leave out masked secrets.
  • The 2.1 upgrade separates old definition alerts from app-created alerts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  AppCode[App code creates an alert] --> Relationship[App-to-alert relationship]
  Relationship --> AppReads[Single and list app reads]
  Event[Change event] --> Mask[ChangeEventMasking]
  Mask --> EventStore[Stored event]
  Update[Entity update] --> Versions[storeVersions]
  Versions --> History[History without hidden fields]
Loading

Reviews (11) · Last reviewed commit: "Update generated TypeScript types and de..." · Reviewed by Greptile

@manerow
manerow requested a review from a team as a code owner October 26, 2026 12:44
@manerow
manerow requested a review from TeddyCr October 26, 2026 12:44
@manerow manerow added safe to test Add this label to run secure Github workflows on PRs backend labels Oct 26, 2026
@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.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 81%
80.93% (136869/169115) 67.82% (49103/72399) 70.88% (27655/39015)

@manerow
manerow force-pushed the fix/qr7d-app-alerts-and-user-secrets branch from d2b8f6d to fee1b75 Compare October 26, 2026 14:21
@manerow manerow changed the title fix: apps no longer create alerts, and user credentials stay out of change events fix: apps no longer create alerts from their definition, and user credentials stay out of change events Oct 26, 2026
@manerow
manerow force-pushed the fix/qr7d-app-alerts-and-user-secrets branch from fee1b75 to 5be0a91 Compare October 26, 2026 15:25
@manerow
manerow force-pushed the fix/qr7d-app-alerts-and-user-secrets branch 2 times, most recently from fc5dd0a to c8ea1c5 Compare October 27, 2026 10:14
@github-actions

Copy link
Copy Markdown
Contributor

The Java checkstyle failed.

Please run mvn spotless:apply in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Java code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-28T23:29:21Z)

Blocked the queue: integration-tests-postgres-elasticsearch-redis

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-29T10:23:46Z)

Blocked the queue: playwright-summary, py-tests-status, integration-tests-postgres-elasticsearch-redis, integration-tests-postgres-opensearch, integration-tests-mysql-elasticsearch

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-10-29T11:05:55Z)

The entry left the queue before it was built, so no checks ran against it.

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-29T15:37:35Z)

Blocked the queue: integration-tests-postgres-elasticsearch-redis

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-29T20:05:35Z)

Blocked the queue: integration-tests-postgres-elasticsearch-redis, py-tests-status, integration-tests-mysql-elasticsearch

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-10-29T20:45:36Z)

The entry left the queue before it was built, so no checks ran against it.

…nd-user-secrets

# Conflicts:
#	bootstrap/sql/migrations/native/2.1.0/mysql/postDataMigrationSQLScript.sql
#	bootstrap/sql/migrations/native/2.1.0/postgres/postDataMigrationSQLScript.sql
#	openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/OntologyConceptRepository.java
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — merge_conflict (2026-10-31T06:01:26Z)

The entry left the queue before it was built, so no checks ran against it.

Applies cleanly to the latest main; it conflicted only with an entry ahead in the queue. Re-queue once that entry has merged or left the queue.

…nd-user-secrets

# Conflicts:
#	bootstrap/sql/migrations/native/2.1.0/mysql/postDataMigrationSQLScript.sql
#	bootstrap/sql/migrations/native/2.1.0/postgres/postDataMigrationSQLScript.sql
@gitar-bot

gitar-bot Bot commented Oct 31, 2026

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

🔴 High risk · The 2.1 migration rewrites stored events, versions, and alert relationships; incorrect targeting could remove history or disable legitimate app notifications.

Removes app-definition alert creation and keeps app-created alerts linked through the server-side relationship, with secrets masked from change events and version history. Resolved this session: added decision records for the two new rules, relationship tests now verify the stored link rather than mock calls, and app history tests check the stored version. No issues found.

✅ 3 closed
✅ Quality: Two new rules (no app alerts, secret fields kept from history) lack records

📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/masker/MaskedFields.java:28-42 📄 openmetadata-service/src/main/java/org/openmetadata/service/events/ChangeEventMasking.java:28-42 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/AccessControlDAOs.java:1161-1175 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:6454-6468 📄 bootstrap/sql/migrations/native/2.0.7/mysql/postDataMigrationSQLScript.sql:1-11 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/alerts/AppEventSubscriptionRemovalIT.java:59-67
This PR makes two decisions that other components and future changes have to respect, and neither is written down. docs/decisions/ gets no new record, and no existing one covers these rules.

  1. Apps no longer carry alerts. eventSubscriptions is removed from app.json, appMarketPlaceDefinition.json and createAppMarketPlaceDefinitionReq.json. A request that still sends it gets a 400. Alerts that apps already created are disabled, not deleted, and unlinked by the 2.0.7 SQL. This is a REST and schema contract change that UI, SDK and ingestion clients must follow. The description gives the reasoning ("No shipped app has used eventSubscriptions, so the field is removed rather than deprecated"), but squash-merge drops the description from history. A record would state: "Apps never create or own event subscriptions; an app or marketplace definition that sends eventSubscriptions is rejected with 400, and alerts left from older app installs are disabled for admin review, not deleted."

  2. Secret-as-a-whole fields are kept out of history and events. MaskedFields, ChangeEventMasking, ChangeEventDAO.insert/insertBatch and EntityRepository.withoutFieldsHiddenFromHistory set this up together: a property whose schema has "mask": true is never stored in, or returned from, change events or version history. Fields that only hold secrets inside them, such as service connections, stay in history and are masked per caller. Every change event must go through the masking insert, and the raw insertMaskedRow(s) methods are only for that path. Both points come from the description ("Version history omits fields the schema marks secret as a whole ... both when stored and on every read"; "Service connections remain in version history, masked per caller as before"). The rule spans the spec, the DAO and the repository, so a future schema author adding mask: true, or a developer adding a new change-event writer, can't tell it applies. A record would state: "A schema property marked mask: true is omitted from every stored change event and entity version, and from every read of them; nested secrets inside a non-masked field stay in history and are masked per caller by the resource; all change-event writes go through ChangeEventDAO.insert/insertBatch."

These are two separate rules, so each needs its own record.

✅ Quality: Relationship tests only check mock calls, never the stored link

📄 openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/AppRepositoryEventSubscriptionsTest.java:108-122
addingAnAlertRecordsTheRelationshipOnce and deletingAnAlertRemovesTheRelationship stub addRelationship/deleteRelationship on a partial mock of AppRepository and then verify() that they were called. The first test is named "once" but asserts times(2), so it really depends on the DB upsert making a repeat insert harmless, and nothing exercises that. If addEventSubscription passed the wrong direction or relation, these tests would still pass, and the repo's testing rules forbid this pattern. Keep the pure storageJsonNode/serializeForVersionHistory/validatePatch unit tests. For add/delete, assert observable state in an IT: after addEventSubscription twice, GET /v1/apps/name/{app}?fields=eventSubscriptions returns exactly one alert, and after delete it returns none.

✅ Quality: App history tests now only check the list, not the stored version

📄 openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/AppRepositoryStorageStrippingTest.java:73-79 📄 openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/AppRepositoryEventSubscriptionsTest.java:67-70 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:6526-6540
getFieldsHiddenFromHistory_declaresRuntimeSecretFields and versionHistoryLeavesOutTheAlertList now only check that getFieldsHiddenFromHistory() returns certain names. The old test serialized a real App and checked that privateConfiguration, openMetadataServerConnection and eventSubscriptions were missing while name stayed. If fieldsHiddenFromHistory() stopped adding the repository's list, or withoutFieldsHiddenFromHistory stopped removing it, both tests would still pass and the app's runtime secrets would go back into stored versions. serializeForVersionHistory is package-private and these tests are in the same package (org.openmetadata.service.jdbi3), so they can keep asserting on the serialized output.

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

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
test — 9ef85f71 Deployed Oct 31, 2026 by manerow via sso-login (ldap, LDAP, --grep @ldap, ldap) #1711
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.

3 participants