Skip to content

Fixes #20753: replace non-schema jobStackTrace with IndexingError.stackTrace - #29965

Merged
mohityadav766 merged 2 commits into
mainfrom
github-issue-20753-schema
Jul 13, 2026
Merged

mohityadav766 merged 2 commits into
mainfrom
github-issue-20753-schema

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #20753

I replaced the ad-hoc, non-schema jobStackTrace map key in the app failure paths with the schema-defined IndexingError.stackTrace field, because failureContext.failure is already typed as IndexingError and the informal key only landed in additionalProperties. OmAppJobListener and DataRetention now build a typed IndexingError (the canonical pattern used across the other apps), and DataRetention's six duplicated failure blocks are collapsed into one helper. DataContractValidationApp keeps its genuinely-mixed error map but renames its top-level key to the schema field. No migration is required: additionalProperties: true keeps historical records valid, nothing reads the key, and the UI already renders failureContext.failure generically.

Type of change:

  • Improvement

High-level design:

N/A — small change.

Tests:

Unit tests

  • Extended OmAppJobListenerTest#jobWasExecuted_setsFailedStatusOnException to assert the failure deserializes to a typed IndexingError with a populated schema stackTrace (fails if the old ad-hoc shape returns).

Backend integration tests

  • Not applicable (no API endpoint changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes — the UI reads failureContext.failure generically).

Manual testing performed

Built openmetadata-service (BUILD SUCCESS), ran the extended unit test (green), and verified mvn spotless:check passes.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #20753 above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: no schema change; explained above why no migration is needed.
  • For UI changes: not applicable.
  • I have added tests (unit) and listed them above.

Greptile Summary

This PR moves app failure details onto the typed IndexingError schema field. The main changes are:

  • Replace ad-hoc jobStackTrace maps with IndexingError.stackTrace.
  • Store DataRetention and job-listener failures through FailureContext.failure.
  • Convert DataContractValidationApp entity failures into failedEntities.
  • Extend the job-listener test for the typed failure payload.

Confidence Score: 4/5

This is close, but the DataRetention failure path should be fixed before merging.

  • A cleanup failure can still be replaced by the synthetic partial-failure exception.
  • The final persisted run can hide the original cleanup error and stack trace.
  • The other changed paths are schema-shape updates and test coverage for typed failure payloads.

openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataRetention/DataRetention.java

Important Files Changed

Filename Overview
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataRetention/DataRetention.java Refactors failure capture to typed IndexingError, but the outer catch can still replace the saved cleanup failure.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataContracts/DataContractValidationApp.java Changes failure details from a mixed map to a typed IndexingError with entity-level failures.
openmetadata-service/src/main/java/org/openmetadata/service/apps/scheduler/OmAppJobListener.java Writes job exceptions as typed IndexingError values in the failure context.
openmetadata-service/src/test/java/org/openmetadata/service/apps/scheduler/OmAppJobListenerTest.java Adds assertions for the typed failure payload and stack trace.

Reviews (2): Last reviewed commit: "Convert DataContractValidationApp failur..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used (3)

  • Context used - CLAUDE.md (source)
  • Context used - openmetadata-ui-core-components/CLAUDE.md (source)
  • Context used - AGENTS.md (source)

…ckTrace

App failure contexts wrote an ad-hoc "jobStackTrace" map key that is not part
of the schema. The failureContext.failure field is already typed as
IndexingError, which has a schema-defined stackTrace field. Use the typed
IndexingError (matching the canonical pattern used across the other apps)
instead of raw maps, deduplicating DataRetention's repeated failure blocks.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 13, 2026 06:51

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This 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 skip-pr-checks label.

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Jul 13, 2026
@mohityadav766 mohityadav766 self-assigned this Jul 13, 2026
Replace the generic Map<String, Object> failure collector with the typed
IndexingError: the top-level exception populates message/stackTrace, and the
per-entity errors go into the schema's failedEntities (EntityError) list
instead of being keyed by FQN in a raw map. Makes all three apps consistent
with the schema-defined failureContext.failure shape.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 13, 2026 07:05

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

failureDetails = new HashMap<>();
failureDetails.put("message", ex.getMessage());
failureDetails.put("jobStackTrace", ExceptionUtils.getStackTrace(ex));
failureDetails = toIndexingError(ex);

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.

P1 First failure overwritten When a cleanup step fails, recordFirstFailure(ex) saves the real cleanup exception and internalStatus becomes ACTIVE_ERROR. startApp() then throws the synthetic partial-failure exception, and this catch replaces failureDetails before the final status update. The persisted run can still show Partial failure occurred in DataRetention job instead of the original cleanup error and stack trace.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (32 flaky)

✅ 4505 passed · ❌ 0 failed · 🟡 32 flaky · ⏭️ 95 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 424 0 3 16
✅ Shard 2 11 0 0 0
🟡 Shard 3 818 0 10 8
🟡 Shard 4 819 0 1 18
🟡 Shard 5 823 0 6 5
🟡 Shard 6 831 0 2 46
🟡 Shard 7 779 0 10 2
🟡 32 flaky test(s) (passed on retry)
  • Pages/AISettings.spec.ts › persists MCP Chat configuration after save (shard 1, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: metric (shard 1, 1 retry)
  • Flow/SearchRBAC.spec.ts › the browse tree only shows the asset-type categories a user can access (shard 1, 1 retry)
  • Features/BulkImportWithDotInName.spec.ts › Full import cycle with dot in service name (shard 3, 1 retry)
  • Features/BulkImportWithDotInName.spec.ts › Import at database level with dot in service name (shard 3, 1 retry)
  • Features/ContextCenterArchivePage.spec.ts › archive page lazy-loads more rows on scroll within its own scroll container (shard 3, 1 retry)
  • Features/ContextCenterArticles.spec.ts › Article listing search filters, clears, and shows empty state (shard 3, 1 retry)
  • Features/ContextCenterArticles.spec.ts › Article list cards, recently viewed widget, and pagination work (shard 3, 1 retry)
  • Features/ContextCenterArticles.spec.ts › description: switching articles does not bleed unsaved content into next article (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › clicking a memory row adds ?memory= param to the URL (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › adding a linked asset in edit mode shows entity badge on the row (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › typing the linked table name in the asset search returns it as a result (shard 3, 1 retry)
  • Features/DataQuality/TestCaseImportExportBasic.spec.ts › should show validation errors for invalid CSV (shard 3, 1 retry)
  • Features/MetricBulkImportExportEdit.spec.ts › New metric row without a name shows error pill and SKIP badge (shard 4, 1 retry)
  • Flow/AddRoleAndAssignToUser.spec.ts › Verify assigned role to new user (shard 5, 1 retry)
  • Flow/ConnectionConfigLayout.spec.ts › should clear inactive Snowflake auth fields before test connection and unlock ingestion filters (shard 5, 1 retry)
  • Flow/ExploreDiscovery.spec.ts › Should display domain and owner of deleted asset in suggestions when showDeleted is on (shard 5, 1 retry)
  • Flow/PersonaDeletionUserProfile.spec.ts › User profile loads correctly before and after persona deletion (shard 5, 1 retry)
  • Flow/PersonaFlow.spec.ts › Set default persona for team should work properly (shard 5, 1 retry)
  • Pages/CustomProperties.spec.ts › Table (shard 5, 1 retry)
  • Pages/EntityDataConsumer.spec.ts › Tier Add, Update and Remove (shard 6, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 6, 1 retry)
  • Pages/ExplorePageRightPanel.spec.ts › Should allow Data Steward to edit tier for searchIndex (shard 7, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Check for Circular Reference in Glossary Import (shard 7, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Import partial success - some terms pass, some fail (shard 7, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify Impact Analysis service filter selection (shard 7, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for pipelineService in platform lineage (shard 7, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for apiService in platform lineage (shard 7, 1 retry)
  • Pages/TasksUIFlow.spec.ts › Create and reject tag task for Topic via UI (shard 7, 1 retry)
  • Pages/TestSuite.spec.ts › Logical TestSuite (shard 7, 1 retry)
  • ... and 2 more

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@mohityadav766 mohityadav766 added the skip-pr-checks Bypass PR metadata validation check label Jul 13, 2026
@mohityadav766
mohityadav766 merged commit a33d41c into main Jul 13, 2026
107 of 109 checks passed
@mohityadav766
mohityadav766 deleted the github-issue-20753-schema branch July 13, 2026 11:04
@gitar-bot

gitar-bot Bot commented Jul 13, 2026

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

Standardizes app failure reporting by replacing ad-hoc stack trace keys with the schema-defined IndexingError.stackTrace field. Collapses duplicate logic in DataRetention and resolves the untyped failure map issue in DataContractValidationApp.

✅ 1 resolved
✅ Quality: DataContractValidationApp still uses untyped failure map

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataContracts/DataContractValidationApp.java:79-80 📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataContracts/DataContractValidationApp.java:272-276
The stated goal of this PR is to align failure reporting with the schema-defined IndexingError field. OmAppJobListener and DataRetention now build a typed IndexingError and call FailureContext.withFailure(...). DataContractValidationApp, however, still populates a bare Map<String,Object> (failureDetails) and sets it via withAdditionalProperty("failure", failureDetails); the diff only renames the inner map key jobStackTrace -> stackTrace.

This leaves an inconsistency: the failure here lands in additionalProperties rather than the typed failure field, so getFailureContext().getFailure() returns null for this app (unlike the other two), and the errorSource value is never set. It functionally works because Jackson's @JsonAnyGetter still emits a failure JSON key the UI reads generically, but the migration is only partial. Consider building a typed IndexingError here as well (mirroring the shared toIndexingError helper) for full consistency and to populate errorSource.

Options

Display: compact → Showing less information.

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

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

mohityadav766 added a commit that referenced this pull request Jul 14, 2026
…a Retention build fix (#29984), realign DataRetention with main (#30030)

* feat(dataRetention): sweep orphan time-series rows for per-type tables (#28384)

* feat(dataRetention): sweep orphan time-series rows for per-type tables

Adds `cleanOrphanedTimeSeriesRows()` to `DataRetention` alongside the existing
orphan-relationship and orphan-tag sweeps. Each of the five affected DAOs gets a
`deleteOrphanedRecords(int limit)` query (MySQL + PostgreSQL) that left-joins
to its parent and deletes rows the parent no longer covers:

- `testCaseResolutionStatus`: parent link via `entity_relationship` PARENT_OF
- `agentExecution`: `agentId` → `ai_application_entity.id`
- `mcpExecution`: `serverId` → `mcp_server_entity.id`
- `profile_data`: `entityFQNHash` → `table_entity.fqnHash`
- `query_cost_time_series`: `entityFQNHash` → `query_entity.fqnHash`

The sweep runs after `cleanOrphanedRelationshipsAndHierarchies()` so the
PARENT_OF check sees the post-cleanup `entity_relationship` state. Pairs with
PR #28367, where the bulk hard-delete cascade now skips time-series children
and relies on `DataRetention` to reclaim them out-of-band.

Adds `OrphanedTimeSeriesCleanupIT` covering all five per-type queries:
inserts a real-parent row and a bogus-parent row through the existing DAO
`insert(...)` paths, runs `deleteOrphanedRecords(BATCH)`, asserts the orphan
is gone and the valid row is preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(dataRetention): fix orphan-cleanup IT name lengths and McpExecution table arg

- McpExecutionDAO.insertWithoutExtension uses `<table>` placeholder; the test
  was passing `null`, which made Jdbi fail to render the SQL template. Pass
  the literal table name `mcp_execution_entity`.
- `ns.prefix(...)` embeds class + method names, so chaining it through
  database -> schema -> table -> auto-created test_suite pushed the test_suite
  `name` column past its VARCHAR(256) bound. Use `ns.uniqueShortId()` for the
  hierarchy components and shorten the test method names so the resulting
  FQN stays well under the column limit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* review(dataRetention): bound profile-data orphan delete by rows + clarify PARENT_OF=9

Addresses two PR review findings:

- `profiler_data_time_series.deleteOrphanedRecords` previously LIMITed distinct
  `entityFQNHash` values, then deleted every row for each hash — a batch could
  delete tens of millions of rows if many orphan hashes each had thousands of
  rows. Switch to row-level limiting: single-table `DELETE ... WHERE NOT EXISTS
  (...) LIMIT N` on MySQL, and `ctid IN (SELECT ... LIMIT N)` on PostgreSQL
  (the table has no `id` column, so we use Postgres ctid for the inner subquery).
  This matches the row-count cap used by the other four orphan-cleanup queries.

- Annotate `er.relation = 9` in the testCaseResolutionStatus query with a
  `// 9 = Relationship.PARENT_OF` inline comment plus a leading block comment
  noting the ordinal is stable because the enum appends new values.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
(cherry picked from commit 5f5a123)

* fix(search-indexing): reclaim orphaned ingestion pipelines and guard null testDefinition during reindex (#29836)

Two reindex failures observed in SearchIndexingApplication that DataRetention did
not cover:

1. Orphaned ingestion pipelines. When a service (or test suite) is hard-deleted
   without the cascade reaching its ingestion pipeline, the pipeline row survives
   with no incoming CONTAINS relationship. Reindex then throws "Entity type
   ingestionPipeline <id> does not have expected relationship contains to/from
   entity type null" because IngestionPipelineRepository.setFields resolves the
   container via getContainer (mustHaveRelationship=true). Nothing swept these.

   Adds OrphanIngestionPipelineCleanup (mirrors OrphanTestCaseRelationshipCleanup)
   wired into DataRetention: pages pipelines, finds ones with no container, and
   hard-deletes them via the standard delete with a force-delete fallback (search
   doc, pipeline-status time series, relationship rows, entity row) since the
   standard delete itself resolves the missing container and throws.

2. NullPointerException building the TestCase search doc. TestCaseIndex called
   testCase.getTestDefinition().getId() with no null check, so a test case whose
   testDefinition relationship is gone NPE'd. Unlike the "expected relationship"
   errors, this NPE is not classified as a stale-reference warning, so it failed
   the reindex outright. Guards the lookup exactly like TestCaseResultIndex does.

Adds OrphanIngestionPipelineCleanupIT covering selective deletion (orphan removed,
healthy pipeline preserved).

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
(cherry picked from commit b8d9f3e)

* Fixes #20753: replace non-schema jobStackTrace with IndexingError.stackTrace (#29965)

* Fixes #20753: replace non-schema jobStackTrace with IndexingError.stackTrace

App failure contexts wrote an ad-hoc "jobStackTrace" map key that is not part
of the schema. The failureContext.failure field is already typed as
IndexingError, which has a schema-defined stackTrace field. Use the typed
IndexingError (matching the canonical pattern used across the other apps)
instead of raw maps, deduplicating DataRetention's repeated failure blocks.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Convert DataContractValidationApp failure to typed IndexingError

Replace the generic Map<String, Object> failure collector with the typed
IndexingError: the top-level exception populates message/stackTrace, and the
per-entity errors go into the schema's failedEntities (EntityError) list
instead of being keyed by FQN in a raw map. Makes all three apps consistent
with the schema-defined failureContext.failure shape.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
(cherry picked from commit a33d41c)

* Fix Data Retention Build Issue (#29984)

* Fix Data Retention Build Issue

* Checkstyle

(cherry picked from commit ee2a438)

---------

Co-authored-by: Sriharsha Chintalapani <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>

This branch was previously deployed

1 inactive deployment
test — a2932cf2 Deployed Jul 13, 2026 by mohityadav766 via playwright-ci-postgresql (4, 7) #56037
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 skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove usage of "jobStackTrace" in applications

3 participants