Skip to content

Reject ingestion pipeline sourceConfig without type - #29566

Merged
ayush-shah merged 18 commits into
mainfrom
ayush-shah/ingestion-source-config-type
Sep 7, 2026
Merged

ayush-shah merged 18 commits into
mainfrom
ayush-shah/ingestion-source-config-type

Conversation

@ayush-shah

@ayush-shah ayush-shah commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Fixes #28818.

Why this is needed

External automation can create ingestion pipelines while omitting the Pydantic-defaulted sourceConfig.config.type discriminator. Those persisted rows cannot be reliably deserialized for later UI redeployment, which is the failure reported in #28818.

What changed

  • Repository validation rejects a missing, null, blank, or non-string sourceConfig.config.type on writes, and rejects non-object configs. Explicit non-blank strings remain unchanged.
  • The v2.1 data migration scans active, non-deleted ingestion pipelines and persists a missing discriminator only when one supported CONTAINS relationship and the pipeline type identify a known source config.
  • Orphaned, ambiguous, malformed, or otherwise unidentifiable legacy records are logged and left unchanged rather than guessed. They can be corrected explicitly.
  • Python BaseWorkflow materializes defaulted source-config discriminators during self-registration, so exclude_unset=True does not omit the required field.
  • The Playwright ingestion-pipeline fixture supplies the discriminator.

Scope

This is a runtime persistence invariant. The JSON schema and generated clients still model some discriminators as optional; aligning that broader contract is intentionally out of scope for this PR.

This PR does not change progress-SSE behavior. The existing stream implementation is unchanged from the merge base.

Validation

  • mvn -pl openmetadata-service -Dtest=IngestionPipelineMigrationUtilTest,IngestionPipelineRepositoryTest test - 77 passed.
  • mvn -pl openmetadata-service spotless:check passed.
  • git diff --check passed.

Greptile Summary

This PR enforces a runtime persistence invariant: sourceConfig.config.type must be a non-blank string on every ingestion pipeline write and deployment, and backfills the discriminator for legacy rows that were persisted without it. The fix spans the Java repository layer (validation in prepare() and deployIngestionPipeline()), a v2.1.0 data migration that repairs existing rows using service CONTAINS relationships, the Python BaseWorkflow self-registration path (forcing the Pydantic default into model_fields_set), and the Playwright fixture that was triggering the now-enforced validation.

  • Repository-layer validation (validateSourceConfigHasType) rejects missing, null, blank, and non-string type on all write paths (POST / PUT / PATCH) and before pipeline deployment, tested end-to-end via raw-HTTP integration tests that bypass SDK serialization.
  • A new IngestionPipelineMigrationUtil batch-scans non-deleted pipelines and writes a repaired type by resolving service-type × pipeline-type pairs; unresolvable rows (orphaned, ambiguous, or malformed) are logged and left unchanged to avoid silent data corruption.
  • BaseWorkflow._source_config_with_explicit_type() copies the source config with type explicitly placed in model_fields_set, so exclude_unset=True serialization no longer omits it during self-registration.

Confidence Score: 5/5

  • Safe to merge. The change tightens an existing invariant, ships a conservative migration (unresolvable rows are left untouched rather than guessed), and is covered by 77 unit tests plus four integration tests that exercise all three HTTP verbs against the live server.
  • All three layers of the fix (repository validation, migration, Python self-registration) are independently unit-tested, and the integration tests confirm end-to-end behavior including the migration repair-then-deploy round trip. The migration is conservative by design: only rows with a single, unambiguous service relationship and a known pipeline-type mapping are repaired; everything else is logged and left unchanged, preventing silent data corruption. The Python change is immutable — the original source config is never modified, only a copy is returned when needed.
  • No files require special attention. The migration utility's static lookup table in IngestionPipelineMigrationUtil.java and the pagination loop are the highest-complexity additions, and both are well-exercised by the test suite.

Important Files Changed

Filename Overview
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/IngestionPipelineRepository.java Adds validateSourceConfigHasType to prepare() and deployIngestionPipeline(), blocking writes and deployments when sourceConfig.config.type is absent, null, blank, or non-string. Handles both raw Map and typed Java object configs with a clear two-condition check.
openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/IngestionPipelineMigrationUtil.java New migration utility that batch-scans non-deleted pipelines and backfills missing sourceConfig.config.type using service CONTAINS relationships and a static service/pipeline-type map. Unresolvable pipelines are conservatively left unchanged and logged. Pagination, deduplication of relationships, and ambiguity handling are all tested.
ingestion/src/metadata/workflow/base.py Adds _source_config_with_explicit_type() that forces the Pydantic-defaulted type discriminator into model_fields_set before self-registration, so exclude_unset=True serialization includes it. The original source_config is never mutated — a copy is returned only when needed.
openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v210/IngestionPipelineMigrationUtilTest.java Comprehensive unit-test suite covering all repair outcomes (NOT_NEEDED, REPAIRED, UNRESOLVED), edge cases like null/blank types, non-string types, malformed config shapes, ReverseIngestion detection, pagination, and same-relationship deduplication.
openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/IngestionPipelineRepositoryTest.java Adds unit tests for validateSourceConfigHasType and deployIngestionPipeline covering null config, empty config, null/blank/non-string types, typed Java objects with default Enum type, and raw-map Enum rejection. Verifies no runner interaction when validation fails.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/IngestionPipelineResourceIT.java Adds four integration tests: POST/PUT/PATCH rejection when type is missing, and migration repair + deployment round-trip. Uses raw HTTP to bypass SDK serialization so the type-missing payload actually reaches the server.
openmetadata-service/src/test/java/org/openmetadata/service/migration/v210/IngestionPipelineMigrationEntryPointTest.java Verifies that both MySQL and PostgreSQL Migration.runDataMigration() call backfillSourceConfigTypes, using static mocking to isolate the entry-point invocation from the utility logic itself.
ingestion/tests/unit/workflow/test_base_workflow.py Adds four focused unit tests verifying that _source_config_with_explicit_type copies correctly when type has a default, does not mutate the original, returns unchanged for raw configs, and does not invent a type when type is explicitly None.
openmetadata-ui/src/main/resources/ui/playwright/support/entity/PipelineClass.ts Adds the required type: 'PipelineMetadata' discriminator to the Playwright ingestion pipeline fixture, preventing Playwright tests from failing against the new validation.
openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v210/Migration.java Wires backfillSourceConfigTypes into the MySQL v2.1.0 data migration runDataMigration step alongside the existing migrations.
openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v210/Migration.java Wires backfillSourceConfigTypes into the PostgreSQL v2.1.0 data migration, mirroring the MySQL change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Client Request\nPOST / PUT / PATCH] --> B[IngestionPipelineRepository.prepare]
    B --> C[validateSourceConfigHasType]
    C --> D{sourceConfig or\nconfig is null?}
    D -- Yes --> E[400 BadRequest\ntype is required]
    D -- No --> F[getSourceConfigMap]
    F --> G{config is Map?}
    G -- Yes --> H[Use config as-is]
    G -- No --> I[JsonUtils.getMap - convert typed obj]
    H --> J[hasSourceConfigType]
    I --> J
    J --> K{type is non-blank\nString?}
    K -- Yes --> L[Validation passes\nWrite to DB]
    K -- No --> M{config NOT Map AND\ntype is Enum?}
    M -- Yes --> L
    M -- No --> E

    N[deployIngestionPipeline] --> C

    O[Migration: backfillSourceConfigTypes] --> P[Batch scan non-deleted pipelines]
    P --> Q[getServiceTypeResolutions via\nCONTAINS relationships]
    Q --> R{sourceConfig.config\nhas explicit type?}
    R -- Yes --> S[NOT_NEEDED - skip]
    R -- No, missing/blank --> T{Service + PipelineType\nresolvable?}
    T -- Yes --> U[Write repaired type to DB]
    T -- No/Ambiguous --> V[UNRESOLVED - log and skip]

    W[Python BaseWorkflow\n_source_config_with_explicit_type] --> X{config is\nOpenMetadataBaseModel?}
    X -- No --> Y[Return unchanged source_config]
    X -- Yes --> Z{type attribute\nis None?}
    Z -- Yes --> Y
    Z -- No --> AA[model_copy with type\nexplicitly in model_fields_set]
    AA --> BB[create_or_update pipeline\ntype serialized even with exclude_unset=True]
Loading

Reviews (20): Last reviewed commit: "test: expand ingestion source config cov..." | Re-trigger Greptile

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Jun 29, 2026
@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.

@ayush-shah
ayush-shah marked this pull request as ready for review June 29, 2026 13:33
@github-actions

github-actions Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

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

@ayush-shah

Copy link
Copy Markdown
Member Author

Pushed a fix for the current migration review thread in 080ec95044: the source-config backfill now uses an explicit service-to-config-type mapping join instead of CASE expressions, so unmatched rows are not written with JSON null.\n\nValidation run locally:\n- git diff --check\n- rtk mvn -pl openmetadata-service -DskipTests=false -Dskip.npm -Dskip.yarn -DskipDocker -Dlicense.skip=true -Dcheckstyle.skip=true -Dspotless.check.skip=true -Dtest=org.openmetadata.service.migration.utils.v200.MigrationUtilTest#backfillsMetadataSourceConfigTypesWithMySqlJsonSet,org.openmetadata.service.migration.utils.v200.MigrationUtilTest#backfillsMetadataSourceConfigTypesWithPostgresJsonbSet test\n- rtk mvn -pl openmetadata-service -DskipTests -Dskip.npm -Dskip.yarn -DskipDocker -Dlicense.skip=true spotless:check

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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread ingestion/src/metadata/workflow/base.py Resolved
Comment thread ingestion/src/metadata/workflow/base.py Resolved
@ayush-shah

Copy link
Copy Markdown
Member Author

The failed downstream compatibility test expected an empty sourceConfig.config to succeed. I opened https://github.com/open-metadata/openmetadata-collate/pull/6300 to assert the new 400 invariant and started the exact compatibility workflow against this PR commit: https://github.com/open-metadata/openmetadata-collate/actions/runs/33415404671. Once the downstream PR is merged, rerun maven-collate-ci here.

@ayush-shah

Copy link
Copy Markdown
Member Author

Status update: downstream test alignment is in https://github.com/open-metadata/openmetadata-collate/pull/6300, and the exact compatibility workflow is now running against this PR head: https://github.com/open-metadata/openmetadata-collate/actions/runs/33415404671.

The test now intentionally expects HTTP 400 with sourceConfig.config.type is required for an empty config. This preserves the persistence invariant introduced here rather than weakening it. After #6300 merges, rerun maven-collate-ci on this PR.

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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

karanh37
karanh37 previously approved these changes Sep 1, 2026
IceS2
IceS2 previously approved these changes Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-01T15:25:42Z)

Blocked the queue: py-tests-status, py-tests-status

  • Integration Tests - PostgreSQL + Elasticsearch + Redis — integration-tests-postgres-elasticsearch-redis, Integration Test Lane (parallel)
  • py-tests-postgres — py-tests-status, python / Verify Expected Jobs, python / Integration Tests (shard-3), python / Integration Tests (shard-2)
  • py-tests — py-tests-status, python / Verify Expected Jobs, python / Integration Tests (shard-3), python / Unit Tests & Static Checks (3.10)

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-02T00:45:09Z)

Blocked the queue: playwright-summary

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-09-02T04:24:21Z)

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

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.

🟢 Approval recommended

The change matches the stated invariant and is backed by targeted unit + integration coverage across validation, migration backfill, and producer serialization paths.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment on lines +545 to 549
private static boolean hasSourceConfigType(Object config, Map<?, ?> configMap) {
Object type = configMap.get(SOURCE_CONFIG_TYPE);
return type instanceof String typeValue && !typeValue.isBlank()
|| !(config instanceof Map<?, ?>) && type instanceof Enum<?>;
}
Comment on lines +368 to +370
private static boolean isMissingOrBlank(JsonNode type) {
return type == null || type.isNull() || type.isTextual() && type.asText().isBlank();
}

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.

🟢 Approval recommended

The invariant is enforced consistently across write/deploy paths, legacy data is backfilled conservatively, and the change is covered by focused unit + integration tests across the affected layers.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — merge_conflict (2026-09-02T17:09:06Z)

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

@gitar-bot

gitar-bot Bot commented Sep 2, 2026

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

Enforces sourceConfig.config.type as a required non-blank string on all ingestion pipeline writes and deployments, with a v2.1 data migration that backfills the discriminator for legacy rows using service CONTAINS relationships. Five findings were resolved during review: the backfill was added to an already-released migration (now wired into v2.1.0 only), scalar sourceConfig.config rows are left unchanged to avoid false repairs, the backfill is scoped to databaseService metadata pipelines, snapshot emission timing is corrected to prevent duplicate events, and ambiguous service-type resolution now explicitly documents the relationship selection. No issues remain open.

✅ 7 resolved
✅ Bug: Backfill added to already-released v1131 migration may never run

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v1131/Migration.java:26 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v1131/Migration.java:26 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1131/MigrationUtil.java:111-125
backfillDatabaseMetadataSourceConfigType is wired into mysql/v1131/Migration and postgres/v1131/Migration. On main the migration tree already contains much newer versions (up through v200 / 2.0.0). OpenMetadata's MigrationWorkflow/MigrationProcessImpl records applied versions in SERVER_CHANGE_LOG and skips runDataMigration() for any version already processed. Any deployment that has already upgraded past 1.13.1 (i.e. nearly every target user of this fix) will never re-execute v1131's runDataMigration(), so the backfill of the 'known persisted bad database metadata pipeline shape' will silently not run for them. Only brand-new installs upgrading through v1131 would get it. The backfill should be placed in the current in-development/unreleased migration version (e.g. v200 / 2.0.0) so it actually executes for existing deployments. Please confirm which version is the active upgrade target before merging.

✅ Edge Case: Backfill no-ops on scalar sourceConfig.config rows, leaving them typeless

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1131/MigrationUtil.java:121-124 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1131/MigrationUtil.java:126-135 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/IngestionPipelineRepository.java:298-312
The backfill WHERE clause only guards sourceConfig.config IS NOT NULL (MySQL JSON_EXTRACT(... '$.sourceConfig.config') IS NOT NULL, Postgres i.json #> '{sourceConfig,config}' IS NOT NULL). If a persisted row stored sourceConfig.config as a scalar (e.g. the string "DatabaseMetadata") rather than an object, the row still matches the predicate, but JSON_SET(..., '$.sourceConfig.config.type', ...) / jsonb_set(..., '{sourceConfig,config,type}', ...) cannot add a member to a scalar and effectively no-ops (MySQL returns the document unchanged; Postgres jsonb_set on a non-object path also yields no member). Those rows therefore remain without a usable type, yet the new validateSourceConfigHasType will reject any subsequent create/update of them with HTTP 400. If the scalar shape is among the 'known bad' shapes this PR intends to fix, it is not covered. Consider detecting/handling the scalar-config case (or asserting it never occurs) and add a test for it.

✅ Edge Case: Backfill only types databaseService metadata pipelines

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v200/MigrationUtil.java:103-117
backfillDatabaseMetadataSourceConfigType only sets sourceConfig.config.type = 'DatabaseMetadata' for pipelines joined via er.fromEntity = 'databaseService' with pipelineType = 'metadata'. Metadata pipelines for other service types (dashboardService, messagingService, etc.) that were also persisted without a sourceConfig.config.type discriminator are not backfilled. If the new repository-level validation (described in the PR summary but not part of this delta) rejects any untyped sourceConfig.config across all service types, those existing pipelines would start failing on their next create/update without a corresponding backfill. If the intent is genuinely database-only, this is fine; otherwise consider broadening the backfill (or adding parallel statements) to cover the other service-type metadata config discriminators. Flagging as minor since the validation code is not in this diff and cannot be verified here.

✅ Edge Case: Snapshot emitted after listener registration can duplicate a live event

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/IngestionPipelineRepository.java:1290-1303 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/IngestionPipelineRepository.java:1316-1322
In the refactored IngestionPipelineRepository.streamProgress, the progress listener is registered before the current snapshot is read and emitted:

progressTracker.registerProgressListener(pipelineFQN, runId, listener);
ProgressUpdate snapshot = getLatestProgressUpdate(pipelineFQN, runId);
if (snapshot != null) {
  emitProgressUpdate(eventSink, sse, snapshot);
}

The previous implementation emitted the snapshot before registering the listener. With the new ordering, if a live ProgressUpdate fires in the window between registerProgressListener and getLatestProgressUpdate, the client receives that update via the listener and then receives the snapshot (which reflects the same or newer state), producing a duplicate initial event. For progress rendering this is benign, but if a terminal (PIPELINE_COMPLETE/ERROR) update arrives via the listener in that window it will close the sink, and the subsequent snapshot emit becomes a no-op via the isClosed() guard — so correctness is preserved, only a possible duplicate remains. Consider reading the snapshot before registering the listener, or de-duplicating by tracking the last emitted update, to avoid the redundant event.

✅ Edge Case: Service type map keeps arbitrary relationship when >1 CONTAINS

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v201/MigrationUtil.java:129-137
getServiceTypes builds toId->fromEntity by forEach put, so if a pipeline id has more than one CONTAINS relationship in the batch, the last record silently wins and may yield the wrong service type for discriminator resolution. Ingestion pipelines normally have a single owning service so impact is low, but consider filtering to the expected service relationship or logging when multiple are found rather than relying on iteration order.

...and 2 more resolved from earlier reviews

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 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion 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.

Bug: Ingestion workflow redeployment fails due to missing sourceConfig.config.type in automated pipeline creation

8 participants