Skip to content

Handle newer Vega-Lite MIME types from Altair 6+#1135

Closed
SAKSHI-DOT693 wants to merge 2 commits intowidgetti:masterfrom
SAKSHI-DOT693:master
Closed

Handle newer Vega-Lite MIME types from Altair 6+#1135
SAKSHI-DOT693 wants to merge 2 commits intowidgetti:masterfrom
SAKSHI-DOT693:master

Conversation

@SAKSHI-DOT693
Copy link
Copy Markdown
Contributor

Altair 6 introduces a new Vega-Lite MIME type (application/vnd.vegalite.v6+json).
FigureAltair currently assumes only v4/v5 MIME variants, which leads to a
KeyError and a full UI crash when charts are rendered with newer Altair
versions.

This change preserves the existing v4/v5 code path and adds a controlled
fallback for newer Vega-Lite MIME types by selecting the first available
Vega-Lite spec exposed by Altair. The intent is to maintain backward
compatibility while avoiding crashes caused by forward MIME version changes.

Notes

No behavior change for Altair ≤ 5

Prevents hard failures with newer Vega-Lite MIME variants

Scoped strictly to Vega-Lite rendering
No behavior change for Altair ≤ 5

Prevents hard failures with newer Vega-Lite MIME variants

Scoped strictly to Vega-Lite rendering

@EwoutH
Copy link
Copy Markdown
Contributor

EwoutH commented Jan 16, 2026

@maartenbreddels could you review this PR?

If this would fix #1127 that would be really useful

@SAKSHI-DOT693
Copy link
Copy Markdown
Contributor Author

Thanks for flagging this and for tagging @maartenbreddels.

This PR focuses specifically on making the Vega-Lite MIME handling more robust for newer Altair versions, by avoiding hard failures when newer MIME types (e.g. v6+) are emitted.

This overlaps with the behavior described in #1127, where the frontend encounters unexpected Vega-Lite state or MIME keys during the initial render.

If you’d prefer this PR to explicitly reference or add coverage for #1127 (e.g. via a small targeted test or adjustment), I’m happy to extend it — just let me know the preferred direction.

@SAKSHI-DOT693
Copy link
Copy Markdown
Contributor Author

I’ve tested this locally on Windows with Altair installed. The updated FigureAltair logic now renders successfully and gracefully selects the available Vega-Lite MIME spec without raising errors. No regressions observed in the existing behavior.

maartenbreddels added a commit that referenced this pull request Jan 21, 2026
Altair 6 introduces a new MIME type format (application/vnd.vegalite.v6.json)
that differs from v4/v5 (+json suffix). Update the MIME type detection to
find any vegalite MIME type instead of hardcoding specific versions.

Based on the issue identified in #1135.

Co-Authored-By: SAKSHI-DOT693 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
@maartenbreddels
Copy link
Copy Markdown
Contributor

Thanks for identifying this issue @SAKSHI-DOT693! I've created #1138 which addresses the same problem with a slightly different approach (scanning for any vegalite MIME type prefix) and includes unit tests. I've credited you as a co-author in the commit.

maartenbreddels added a commit that referenced this pull request Jan 21, 2026
Altair 6 introduces a new MIME type format (application/vnd.vegalite.v6.json)
that differs from v4/v5 (+json suffix). Update the MIME type detection to
find any vegalite MIME type instead of hardcoding specific versions.

Based on the issue identified in #1135.

Co-Authored-By: SAKSHI-DOT693 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

4 participants