Skip to content

Fixes #32639: deserialize and decrypt ingestion-bot JWT token in K8sPipelineClient - #32708

Merged
pmbrull merged 1 commit into
mainfrom
detail/bug-fix/fixes-32639-deserialize-and-decrypt-ingestion-bot-fcf650
Sep 7, 2026
Merged

pmbrull merged 1 commit into
mainfrom
detail/bug-fix/fixes-32639-deserialize-and-decrypt-ingestion-bot-fcf650

Conversation

@detail-app

@detail-app detail-app Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #32639

I worked on fixing K8sPipelineClient.getIngestionBotToken(), which cast the bot user's authenticationMechanism.config directly to JWTAuthMechanism and returned the raw getJWTToken(). Because config is typed Object with no polymorphic typing, after a production DB-load it deserializes to a LinkedHashMap, so the cast threw ClassCastException (swallowed → null), and createDefaultServerConnection() surfaced it as IllegalStateException("Failed to retrieve ingestion-bot JWT token"). The method also never decrypted the stored @PasswordField JWT token, so even a cast-free read would have shipped Fernet ciphertext (or a secret:/ reference) instead of a usable bearer token.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

The fix mirrors the existing reference implementations OpenMetadataConnectionBuilder.extractSecurityConfig and OpenMetadataOperations.getIngestionBotToken:

  • JsonUtils.convertValue(authMechanism.getConfig(), JWTAuthMechanism.class) instead of the direct cast — handles both the LinkedHashMap (DB/JSON-loaded) and POJO cases.
  • SecretsManagerFactory.getSecretsManager().decryptJWTAuthMechanism(jwtAuth) to Fernet-decrypt the stored token (guarded by secretsManager != null to preserve unit-test behaviour where the SM isn't bootstrapped).
  • isSecret(token) / getSecretValue(token) to resolve secret:/... references under external SecretsManagers.

This is the same acquisition pattern (SecretsManagerFactory.getSecretsManager()) already used at the equivalent call sites in IngestionPipelineResource.decryptOrNullify and IngestionPipelineRepository.deployPipelineBeforeUpdate; no constructor-injection change is required.

Tests:

Use cases covered

  • getIngestionBotToken() returns the JWT token when the ingestion-bot User is materialised the way the live server does it (deserialised from stored JSON, so config is a LinkedHashMap).
  • createDefaultServerConnection() builds a non-null OpenMetadataConnection whose securityConfig.jwtToken carries the resolved token (no IllegalStateException).

Unit tests

  • I added unit tests for the changed logic.
  • Files added: openmetadata-service/src/test/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClientBotTokenBugTest.java
  • The two test cases materialise the bot user via JsonUtils.readValue(json, User.class) (so config is a LinkedHashMap, matching the production userRepository.getByName path), mock Entity.getEntityRepository(BOT/USER), and invoke the private getIngestionBotToken / createDefaultServerConnection via reflection. They fail on the buggy code (ClassCastException → null → IllegalStateException) and pass with the fix.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  • Ran the full openmetadata-service surefire suite (8657 tests, 0 failures) to confirm no regressions from the SecretsManagerFactory.getSecretsManager() acquisition pattern.
  • Built the fixed openmetadata-service jar from source and ran it against MySQL + Elasticsearch + a real Kubernetes API server (kwok, kube-apiserver v1.30.4) with K8sPipelineClient selected. Triggered AutoPilot first-create-and-deploy on a fresh database service; confirmed no ClassCastException or IllegalStateException: Failed to retrieve ingestion-bot JWT token in the server logs — the deploy reached real Kubernetes API resource creation without the bug's failure mode. (Full CronJob creation could not complete due to the kwok sandbox's K8s API limitations — 404 on the scheduled resource — which is unrelated to this bug.)
  • Confirmed the ingestion-bot's stored JWTToken in the production DB is Fernet ciphertext (fernet:gAAAAA...), matching the encrypted state the fix's decrypt step handles.

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 #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing. For complex issues, comment the issue number in the test for future reference.

Automatic Fixes PRs can be configured here.

@detail-app
detail-app Bot requested a review from a team as a code owner September 6, 2026 06:29
@detail-app
detail-app Bot requested a review from pmbrull September 6, 2026 06:29
@github-actions

github-actions Bot commented Sep 6, 2026

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!

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 5a8a1bffae2e811bca978107784075a708c0e715 in Playwright run 34044864267, attempt 1.

✅ 619 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 50m 57s

⏱️ Max setup 4m 37s · max shard execution 18m 39s · max shard-job elapsed before upload 22m 1s · reporting 6s

🌐 241.08 requests/attempt · 2.74 app boots/UI scenario · 11.35% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 241.08 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.74 per UI scenario (1779 boots / 649 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 147 0 0 0 0 0
✅ Shard chromium-02 130 0 0 0 0 0
✅ Shard chromium-03 122 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 24 0 0 0 0 0
✅ Shard ingestion-02 39 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

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

@pmbrull
pmbrull added this pull request to the merge queue Sep 7, 2026
Merged via the queue into main with commit 94d6c45 Sep 7, 2026
182 of 196 checks passed
@pmbrull
pmbrull deleted the detail/bug-fix/fixes-32639-deserialize-and-decrypt-ingestion-bot-fcf650 branch September 7, 2026 16:16
pmbrull pushed a commit that referenced this pull request Sep 8, 2026
…32708)

Co-authored-by: detail-app[bot] <180357370+detail-app[bot]@users.noreply.github.com>
@pmbrull

pmbrull commented Sep 8, 2026

Copy link
Copy Markdown
Member

picked to 2.0

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

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.

[Detail Bug] K8s pipeline deployments fail on first AutoPilot create due to ingestion-bot JWT token not deserialized/decrypted

1 participant