Handle newer Vega-Lite MIME types from Altair 6+#1135
Handle newer Vega-Lite MIME types from Altair 6+#1135SAKSHI-DOT693 wants to merge 2 commits intowidgetti:masterfrom
Conversation
|
@maartenbreddels could you review this PR? If this would fix #1127 that would be really useful |
|
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. |
|
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. |
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]>
|
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. |
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]>
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