Repository navigation
Fixes #32639: deserialize and decrypt ingestion-bot JWT token in K8sPipelineClient - #32708
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ Playwright Results — workflow succeededValidated commit ✅ 619 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking 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:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…32708) Co-authored-by: detail-app[bot] <180357370+detail-app[bot]@users.noreply.github.com>
|
picked to 2.0 |
Detail bug report: View on Detail
Describe your changes:
Fixes #32639
I worked on fixing
K8sPipelineClient.getIngestionBotToken(), which cast the bot user'sauthenticationMechanism.configdirectly toJWTAuthMechanismand returned the rawgetJWTToken(). Becauseconfigis typedObjectwith no polymorphic typing, after a production DB-load it deserializes to aLinkedHashMap, so the cast threwClassCastException(swallowed →null), andcreateDefaultServerConnection()surfaced it asIllegalStateException("Failed to retrieve ingestion-bot JWT token"). The method also never decrypted the stored@PasswordFieldJWT token, so even a cast-free read would have shipped Fernet ciphertext (or asecret:/reference) instead of a usable bearer token.Type of change:
High-level design:
N/A — small change.
The fix mirrors the existing reference implementations
OpenMetadataConnectionBuilder.extractSecurityConfigandOpenMetadataOperations.getIngestionBotToken:JsonUtils.convertValue(authMechanism.getConfig(), JWTAuthMechanism.class)instead of the direct cast — handles both theLinkedHashMap(DB/JSON-loaded) and POJO cases.SecretsManagerFactory.getSecretsManager().decryptJWTAuthMechanism(jwtAuth)to Fernet-decrypt the stored token (guarded bysecretsManager != nullto preserve unit-test behaviour where the SM isn't bootstrapped).isSecret(token)/getSecretValue(token)to resolvesecret:/...references under external SecretsManagers.This is the same acquisition pattern (
SecretsManagerFactory.getSecretsManager()) already used at the equivalent call sites inIngestionPipelineResource.decryptOrNullifyandIngestionPipelineRepository.deployPipelineBeforeUpdate; no constructor-injection change is required.Tests:
Use cases covered
getIngestionBotToken()returns the JWT token when the ingestion-botUseris materialised the way the live server does it (deserialised from stored JSON, soconfigis aLinkedHashMap).createDefaultServerConnection()builds a non-nullOpenMetadataConnectionwhosesecurityConfig.jwtTokencarries the resolved token (noIllegalStateException).Unit tests
openmetadata-service/src/test/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClientBotTokenBugTest.javaJsonUtils.readValue(json, User.class)(soconfigis aLinkedHashMap, matching the productionuserRepository.getByNamepath), mockEntity.getEntityRepository(BOT/USER), and invoke the privategetIngestionBotToken/createDefaultServerConnectionvia reflection. They fail on the buggy code (ClassCastException→null→IllegalStateException) and pass with the fix.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
openmetadata-servicesurefire suite (8657 tests, 0 failures) to confirm no regressions from theSecretsManagerFactory.getSecretsManager()acquisition pattern.openmetadata-servicejar from source and ran it against MySQL + Elasticsearch + a real Kubernetes API server (kwok, kube-apiserver v1.30.4) withK8sPipelineClientselected. Triggered AutoPilot first-create-and-deploy on a fresh database service; confirmed noClassCastExceptionorIllegalStateException: Failed to retrieve ingestion-bot JWT tokenin 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.)JWTTokenin 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:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Automatic Fixes PRs can be configured here.