Skip to content

Fixes 25420: Alation Sink no longer crashes at the end of a run and surfaces Alation's errors - #36066

Merged
Khairajani merged 8 commits into
mainfrom
fix/25420-alation-sink
Oct 26, 2026
Merged

Khairajani merged 8 commits into
mainfrom
fix/25420-alation-sink

Conversation

@Khairajani

@Khairajani Khairajani commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #25420

Client-side bugs in the Alation Sink connector; none involve the OpenMetadata server:

  • Crash at the end of every run. AlationsinkSource._iter never yielded, so it returned None and Source.run failed with 'NoneType' object is not iterable after all writes had finished. It now ends with yield from ().
  • Failed to write entities: 'message'. Alation error bodies carry code/detail and no message, so APIError.__init__ raised KeyError and dropped Alation's explanation. It now falls back to detail, then title, then the whole body.
  • Alation jobs were never checked. Schema/table/column writes return a job_id; the sink took that as success. Each write now polls /api/v1/bulk_metadata/job/ until the job finishes (timeout = failure), and a failed job or the per-object errors of a successful one are recorded on the status with Alation's message.
  • Unbatched writes. All tables of a schema, or all columns of a table, went out in one request. Writes are now batched at 1000, the default of Alation's own SDK (Allie-SDK) — a plausible cause of the rejected wide-table write in the issue.
  • Datasource id. Without datasourceLinks, the created datasource's id was read as an attribute of a dict, so that path could never work.

Record: ADR:2026-10-23-alation-sink-writes-in-batches-and-waits-for-each-job.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • A run completes with no Unhandled failure.
  • A job that runs then succeeds, fails, succeeds with rejected objects, or never finishes; a write with no job.
  • 2,500 columns go out as batches of 1000 / 1000 / 500.
  • A rejected column write is reported for its table; other tables are still written.
  • APIError built from a body without message reports detail/title.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added: alationsink/test_client.py, alationsink/test_metadata.py, ometa/test_api_error.py. Each fails against the code before its fix.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no integration tests changed; unit-level coverage of the run loop).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Alation can't run locally, so each run below writes to a fake Alation server that returns Alation-shaped responses.

  1. Issue repro. The real source and REST client were run against a fake server that rejects one column batch with code/title/detail and no message.
    • Before the fix, both log lines from the issue appear.
    • After the fix, the run completes, the log shows the server's detail, and the status names the rejected table.
  2. Wide tables, end to end. Local OM seeded with tables of 5 / 300 / 1,000 / 1,500 / 3,000 columns, full MetadataWorkflow (CLI path), fake Alation answering with jobs (running, then the outcome):
    • Tables read from the real OM server with no 413/504.
    • The 3,000-column table goes out as 3 POSTs of 1,000; every job is polled to completion.
    • When a job rejects objects, the run fails that table with Alation's errors (75%); before, the run crashed with NoneType and never checked jobs.
  3. Related unit tests. 53 tests pass: alationsink, APIError, REST client resilience, ometa restore and dbt config errors.

Not tested: real Alation. Job shapes and the batch size come from Alation's SDK and docs.

UI screen recording:

Not applicable — ingestion-only bug fix.

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 #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md and fixed every 🔴 finding.
  • Decision check: batch size and job timeout recorded in ADR:2026-10-23-alation-sink-writes-in-batches-and-waits-for-each-job.
  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code


Summary by Gitar

  • Batched writes:
    • Schema, table and column writes are sent in batches of WRITE_BATCH_SIZE (1000)
  • Job polling:
    • Each batch's /bulk_metadata/job/ is polled with backoff until done, failing after JOB_TIMEOUT_SECONDS
    • Failed jobs and per-object job errors are recorded on the run status
  • Decision record:
    • Added ADR 2026-10-23-alation-sink-writes-in-batches-and-waits-for-each-job.md

This will update automatically on new commits.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with a remaining non-blocking concern about the job timeout.

Findings

  1. P2 Job waits exceed their limit ▶

Summary

The Alation Sink now writes in batches and waits for Alation jobs before continuing.

  • Alation metadata writes now run in batches and wait for each job.
  • Alation write failures now show up in the ingestion run status.
  • The Alation Sink completes runs and uses IDs from new datasources.
  • API errors now show Alation’s explanation when message is missing.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Schema, table, or column requests] --> B[Split into batches of 1000]
    B --> C[Post batch to Alation]
    C --> D{Job returned?}
    D -->|Yes| E[Poll until finished or timed out]
    D -->|No| F[Use immediate response]
    E --> G[Collect job and object errors]
    F --> G
    G --> H[Record failures and continue]
Loading

Reviews (7) · Last reviewed commit: "Merge branch 'main' into fix/25420-alati..." · Reviewed by Greptile

…urfaces Alation's errors

_iter never yielded, so Source.run iterated None and every run ended in
'NoneType' object is not iterable. APIError read error["message"], which
Alation error bodies lack, so a rejected write logged only 'message'.
Rejected writes are now recorded on the status instead of passing silently.
@Khairajani
Khairajani requested a review from a team as a code owner October 23, 2026 07:03
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

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

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@Khairajani Khairajani added the safe to test Add this label to run secure Github workflows on PRs label Oct 23, 2026

@harshsoni2024 harshsoni2024 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.

The crash and immediate error handling fixes look useful. I found one remaining gap before merge:

  • Alation’s schema, table, and column POSTs return asynchronous job IDs. A truthy response means the upload was accepted, but the job can later reject objects. Please check the job result before marking the write successful.

Schema, table and column writes return a job id; a failed job, or the
per-object errors of a successful one, is now recorded on the status
instead of the job id counting as success. Writes are batched at 1000,
the default of Alation's own SDK. Also read the created datasource's id
from the response dict, which the no-datasourceLinks path never could.
@github-actions

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

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

Use lazy logging for the new write logs and prune the two G004 baseline
entries for the f-string logs they replaced.
Comment on lines +237 to +240
deadline = time.monotonic() + JOB_TIMEOUT_SECONDS
interval = JOB_POLL_INITIAL_INTERVAL_SECONDS
while True:
job = self.jobs_client.get("/bulk_metadata/job/", data={"id": job_id}) or {}

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 Job waits exceed their limit

_wait_for_job checks its deadline only after the GET returns. Each poll uses the REST client's default 300-second read timeout and retries, so a poll started just before the deadline can hold up the run for several more minutes. Check the remaining time before each poll and limit the request timeout and retries to that budget.

Check the job deadline before every poll and never sleep past it, and give
the job client a 30s read timeout with no retries, so a wait overruns its
timeout by at most one poll. State the five-error cap on the run status in
the decision record.
Khairajani and others added 3 commits October 23, 2026 17:10
With retries off, one 5xx or timed-out poll failed a batch whose job may
still succeed. A transient failure (transport, 429, 5xx) is now retried
by the next poll until the deadline, reported with the last poll error;
any other failure still fails the batch at once.
Index ROUTES directly, pass hostPort to clean_uri as a string, and read a
job poll only when it decoded to a dict. ingest_tables now keeps the tables
that pass the filter instead of filtering again before the column writes,
which also stops a filtered table being counted twice on the status.
@gitar-bot

gitar-bot Bot commented Oct 26, 2026

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

🟡 Medium risk · Batching Alation metadata writes and adding job polling changes delivery semantics; timeout or response mismatches could leave records incomplete or flag successful writes.

Fixes the Alation Sink end-of-run crash by ending the source iterator with yield from (), surfaces Alation's error detail/title in APIError, and batches writes at 1000 while polling each job to completion. Resolved review findings: the reported-errors cap of 5 is now documented against the ADR, and transient poll errors are retried so one failure no longer fails a batch.

✅ 2 closed
✅ Quality: MAX_REPORTED_ERRORS cap of 5 is a new limit not stated in the ADR

📄 ingestion/src/metadata/ingestion/source/metadata/alationsink/metadata.py:70 📄 ingestion/src/metadata/ingestion/source/metadata/alationsink/metadata.py:273-274 📄 docs/decisions/2026-10-23-alation-sink-writes-in-batches-and-waits-for-each-job.md:23
This commit adds MAX_REPORTED_ERRORS = 5 (metadata.py:70). It caps how many of Alation's errors go into each StackTraceError on the run status, and everything past five is reduced to "(and N more)". Picking 5 is a judgment call, and it changes what users see in the run report. The new record 2026-10-23-alation-sink-writes-in-batches-and-waits-for-each-job covers the batch size, poll intervals and timeout, but says nothing about this cap. Its Decision bullet even says "every per-object error of a successful one, is recorded on the run status", and with the cap that is no longer true: only the first five are recorded and the rest appear only in the logs.

The rule the record should state: "A failed write is recorded on the run status with at most the first 5 of Alation's errors plus a count of the rest. The full list is logged." Either add that to the existing record's Decision section, or drop the cap.

✅ Bug: retry=0 makes one transient poll error fail a batch that may succeed

📄 ingestion/src/metadata/ingestion/source/metadata/alationsink/client.py:121-126 📄 ingestion/src/metadata/ingestion/source/metadata/alationsink/client.py:246-255 📄 ingestion/src/metadata/ingestion/source/metadata/alationsink/client.py:229-231
Setting retry=0 on jobs_client also turns off REST._one_request's retry on 503/504 (resp.status_code in retry_codes and retry > 0). A single gateway hiccup during a wait of up to 10 minutes now raises HTTPError out of _wait_for_job. The same happens when one poll runs past the new 30 s read timeout, which raises RestTransportError. _write_batch catches the exception and reports the whole batch as failed, but the Alation job keeps running and may well succeed, so the run status says tables or columns are missing when they were written. You can keep the bound on each poll and still be robust: catch exceptions per poll inside _wait_for_job, log them, and keep polling until the deadline. Only give up with the last error once the deadline has passed.

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

@Khairajani
Khairajani added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 44a6612 Oct 26, 2026
85 checks passed
@Khairajani
Khairajani deleted the fix/25420-alation-sink branch October 26, 2026 07:38
Khairajani added a commit that referenced this pull request Nov 16, 2026
…ce and routes lineage by project (#37855)

* Fixes #37777: MicroStrategy skips documents, parses cube SQL once and routes lineage by project (#37778)

* MicroStrategy: skip documents, parse cube SQL once, dedupe columns

- Tell Report Services documents, templates and themes from dossiers by
  viewMedia (the rule MicroStrategy's mstrio-py SDK uses) and skip them
  before reading a definition the dossier API cannot serve.
- Parse each cube's SQL once per cube and dialect instead of once per
  dbServicePrefixes entry and dossier; skip a prefix whose database does
  not match the table's qualifier.
- Give repeated data model column names a suffix, and drop a repeated object.
- Say when a dataset is a report rather than a cube.

* MicroStrategy: suffix repeated column names in id order

A dataset can list its objects in another order on a later run; suffixes
given in listing order would then move a column name to another object.

(cherry picked from commit e994f52)

* ingestion: read an API error without a message key

MicroStrategy answers some errors with only code and ticketId, and
APIError raised KeyError: 'message' while being built. Backports the
fallback main has had since #36066.

* MicroStrategy: bound the service lookup caches

The dialect and database-name caches are now LRUs capped at CACHE_SIZE,
like the connector's other caches, and database names are read with
model_str.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Alation Ingestion fails with TypeError: 'NoneType' object is not iterable on tables with large column counts

2 participants