Skip to content

feat(superset): connection mutator that forwards the user's token, refresh fix and per-user cache - #999

Merged
malon64 merged 2 commits into
mainfrom
feat(superset)/trino-connection-mutator
Nov 8, 2026
Merged

malon64 merged 2 commits into
mainfrom
feat(superset)/trino-connection-mutator

Conversation

@malon64

@malon64 malon64 commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Closes #986 (slice 4.2 of #968, tracker #960). 11 files, about 330 changed lines.

What changed

  • images/superset/olf_trino.py:
    • db_connection_mutator sets extra_credential=[("token", t)] and user=<email> for a Trino connection that carries a bearer in http_session. It strips a URI password, which would otherwise replace the bearer, and copies verify onto the supplied session. With no bearer, or a non-Trino engine, it changes nothing.
    • install() wraps TrinoEngineSpec.get_oauth2_fresh_token. A 400/401 from Dex becomes TrinoAuthError, so Superset deletes the refused token and the user signs in again. It also stores expires_in - 60.
  • olf_oidc.trino_settings (used only by the openlakeforge_oidc override, so only with people's access):
    • DATABASE_OAUTH2_CLIENTS["Trino"] on the superset Dex client, with request_content_type: "data" because Dex takes a form body.
    • DATABASE_OAUTH2_REDIRECT_URI per stage.
    • CACHE_QUERY_BY_USER and CACHE_IMPERSONATION on; ALERT_REPORTS and THUMBNAILS off.
    • VIZ_TYPE_DENYLIST lists the 28 legacy viz.py types, taken from the 6.1.0 source.
  • Terraform: the Superset module's oidc object gains database_redirect_uri and people_catalog. The local environment sets them, and the Dex superset client accepts the extra redirect /api/v1/database/oauth2/.
  • Dockerfile: trino==0.340.0 (was >=0.336,<1) and olf_trino.py is copied into the image.
  • patch_trino_iceberg_partitions.py: _is_iceberg_database now matches the last URI segment against OLF_ICEBERG_CATALOGS (["iceberg", "<stage>"]). ADR 0019 item 7 names the stage's people catalog <stage>.
  • Tests: test_superset_trino.py, plus one assertion updated in test_superset_oidc.py.

Verified against source

I read the Superset 6.1.0 wheel and trino 0.340.0 for core.py (mutator call site and signature), utils/oauth2.py (refresh and delete-on-oauth2_exception), base.py (get_oauth2_fresh_token), trino.py (impersonate_user), viz.py, and the trino dbapi/dialect handling of http_session, verify and password.

Notes

  • The spike(S2): Superset per-user OAuth2 token reaches Polaris through Trino #962 comment carries the findings, not the module. I wrote the module from the issue scope plus the Superset source.
  • The "image tests" run in tools/olf/tests with Superset and trino stubbed, like the existing test_superset_oidc.py. They cover headers, refresh, a refused refresh token, and no bearer leaving the connection unchanged. They do not run a fake Trino or Dex over HTTP inside the image.
  • Gates: ruff and mypy clean. pytest passes (3360 passed, coverage 86.7%). olf check all passes the Terraform and container checks, then stops at "project-code check requires Python >=3.12,<3.13; found 3.13". That is this sandbox's interpreter and unrelated to the change. terraform fmt was not available here, and I aligned the HCL by hand.

Not done, noted for later

  • The Dex trustedPeers entry (olf-cli trusting superset) is not in this issue's scope. The audience:server:client_id:olf-cli scope will be refused until it exists, so it must land before slice 4.3.
  • ADR 0019 already states the mutator approach and "Decided, not built" lists nothing this slice completes, so I left it unchanged.

Release note

Superset image: adds a Trino connection mutator and refresh fix, inert until a per-user database is imported.

Runtime verification (kind e2e) pending: done by the coordinator

The Superset image must be rebuilt and loaded locally. The mutator is not in the published digest, so run BUILD_SUPERSET_IMAGE=true olf infra deploy --provider local, or olf images build superset then olf infra images load superset. Then check:

  1. olf infra e2e run --env local is unchanged. Superset starts with the new config, the people login works, and the existing dashboards render with no per-user database.
  2. The Superset pod log shows no import error for olf_trino or olf_oidc.trino_settings.
  3. The Dex superset client lists both redirects: /oauth-authorized/olf and /api/v1/database/oauth2/.
  4. With SUPERSET_BASE_IMAGE unchanged, pip show trino in the image reports 0.340.0.
  5. SQL Lab on the existing shared Iceberg database still previews tables without the partition error.

Generated by Claude Code

…ed refresh

A DB_CONNECTION_MUTATOR sets the token extra credential and the email
user for a Trino connection that carries a bearer, and a patch of
Superset's refresh turns a refused Dex refresh token into a new sign-in.
Per-user caching is on and alerts, thumbnails and legacy chart types are
off. Inert until a per-user database is imported (#968 slice 4.3).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UVCVTjBeDDjt4VS5rJeaPi
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T20:39:30.876417Z
We couldn’t complete this review. Comment @codex review to try again.
9212af2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

…connection-mutator

# Conflicts:
#	infra/terraform/environments/local/contracts.tf
#	tools/olf/tests/infra/test_superset_oidc.py
@malon64
malon64 added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 0639f85 Nov 8, 2026
12 checks passed
@malon64
malon64 deleted the feat(superset)/trino-connection-mutator branch November 8, 2026 12:08
mkumar1205-beep pushed a commit to mkumar1205-beep/openlakeforge that referenced this pull request Nov 24, 2026
Publish a Superset image built from the current images/superset: the digest
pinned since 0.5.0-alpha.1 predates OpenLakeForge#999, so a fresh `olf infra deploy` from
main crashes the Superset pods with `ImportError: cannot import name
'trino_settings' from 'olf_oidc'` and the platform apply times out on
helm_release.superset (OpenLakeForge#1018). This bump only cuts the release; the digest
pin and the drift guard follow in the OpenLakeForge#1018 fix once the image exists.
mkumar1205-beep pushed a commit to mkumar1205-beep/openlakeforge that referenced this pull request Nov 24, 2026
…ift (OpenLakeForge#1018) (OpenLakeForge#1073)

* feat(release): guard catalog image pins against their build source

`olf release check` (through `olf check components`) now fails when the
source a pinned image was built from changes without the image being
republished and its digest repinned. `components.image_sources` records a
fingerprint of `images/<image>` (everything but the README, which never
enters the build context) plus the catalog's build-input pins, so a base
bump also invalidates it.

The superset pin once lagged `images/superset` by three days after OpenLakeForge#999:
a deploy of main crashed the Superset pods on `ImportError` because
`superset_config.py` imported `trino_settings` the pinned image predates
(OpenLakeForge#1018). The digest pin and the recorded fingerprint for this tree follow
in the same PR once the 0.5.1-alpha.3 release publishes the image.

* fix(release): repin the superset image to the 0.5.1-alpha.3 build

The pinned digest (0.5.0-alpha.1) predates OpenLakeForge#999: superset_config.py
imports trino_settings from olf_oidc, which exists only in images built
from the current images/superset, so a fresh olf infra deploy on amd64
crashed the Superset web and worker pods and timed out the platform apply
on helm_release.superset (OpenLakeForge#1018).

The digest is the one the v0.5.1-alpha.3 release workflow published and
signed from this same tree (release-assets-superset artifact); the source
fingerprint recorded beside it in the catalog proves they match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(superset): connection mutator that forwards the user's token, refresh fix and per-user cache (#968 slice 4.2)

2 participants