Skip to content

fix: strip quotes and whitespace from %env values in ipynb conversion - #10904

Merged
mscolnick merged 1 commit into
marimo-team:mainfrom
Oscar-Williams:fix/10903-env-magic-quotes
Sep 21, 2026
Merged

mscolnick merged 1 commit into
marimo-team:mainfrom
Oscar-Williams:fix/10903-env-magic-quotes

Conversation

@Oscar-Williams

Copy link
Copy Markdown
Contributor

This pull request was authored by a coding agent.

📝 Summary

Closes #10903

magic_env in the ipynb converter now mirrors IPython's %env semantics: surrounding whitespace is stripped from both the variable name and the value, one pair of matching surrounding quotes is removed from the value, and a %env VAR line without = converts to the standard unsupported-magic comment instead of raising ValueError. Added a regression test covering quoted values, spaced KEY = VALUE forms, the plain case, and the KEY-less form.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (not applicable; this is a small bug fix).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes (not applicable).
  • Tests have been added for the changes made.

Validation: tests/_convert/ passes with 356 tests (including the new %env regression case); ruff check and ruff format --check pass on the touched files; mypy passes on marimo/_convert/ipynb/to_ir.py.

%env cells converted with a raw split("=", 1), so shell quoting and
surrounding whitespace leaked into the generated os.environ assignment:
%env VAR="hello world" kept the quotes in the value and %env VAR = value
produced a key with a trailing space. %env with no '=' also crashed the
transform with ValueError (caught upstream, leaving a noisy traceback and
an unconverted cell).

Mirror IPython's env-magic semantics: strip whitespace around both sides,
remove one pair of matching surrounding quotes from the value, and convert
a KEY-less form to the standard unsupported-magic comment instead of
raising.
@vercel

vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
marimo-docs Ready Ready Preview Sep 18, 2026 6:08pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Oscar-Williams
Oscar-Williams marked this pull request as ready for review September 18, 2026 18:46
@mscolnick mscolnick added the bug Something isn't working label Sep 21, 2026
@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Bundle Report

Changes will decrease total bundle size by 83.42kB (-0.31%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 26.45MB -83.42kB (-0.31%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-*.js 691.53kB 1.33MB 108.59% ⚠️
assets/cells-*.js -15.56kB 976.85kB -1.57%
assets/terminal-*.js -10 bytes 449.38kB -0.0%
assets/edit-*.js 1.6kB 442.03kB 0.36%
assets/index-*.css 3.65kB 381.83kB 0.97%
assets/RunButton-*.js -779 bytes 366.6kB -0.21%
assets/dist-*.js 320 bytes 26.77kB 1.21%
assets/dist-*.js (Deleted) -513 bytes 0 bytes -100.0% 🗑️
assets/ai-*.js 483 bytes 315.87kB 0.15%
assets/panels-*.js -1.24kB 267.06kB -0.46%
assets/glide-*.js 4.3kB 262.12kB 1.67%
assets/reveal-*.js -148 bytes 257.8kB -0.06%
assets/dependency-*.js 1.01kB 162.35kB 0.63%
assets/agent-*.js -330 bytes 153.65kB -0.21%
assets/add-*.js -1.98kB 147.79kB -1.32%
assets/ConnectedDataExplorerComponent-*.js -143 bytes 134.73kB -0.11%
assets/swiper-*.js -15 bytes 116.58kB -0.01%
assets/file-*.js -51 bytes 113.06kB -0.05%
assets/file-*.js -325 bytes 78.44kB -0.41%
assets/file-*.js (Deleted) -805 bytes 0 bytes -100.0% 🗑️
assets/mermaid-*.js -6 bytes 92.25kB -0.01%
assets/input-*.js 3.94kB 85.56kB 4.82%
assets/chat-*.js -115 bytes 15.05kB -0.76%
assets/chat-*.js -159 bytes 16.23kB -0.97%
assets/chat-*.js -173 bytes 37.4kB -0.46%
assets/dagre-*.js -31 bytes 32.96kB -0.09%
assets/session-*.js -130 bytes 27.32kB -0.47%
assets/tooltip-*.js -32 bytes 9.57kB -0.33%
assets/select-*.js -35 bytes 25.1kB -0.14%
assets/dropdown-*.js 4 bytes 22.94kB 0.02%
assets/packages-*.js 1.15kB 18.97kB 6.42% ⚠️
assets/home-*.js -183 bytes 18.41kB -0.98%
assets/toast-*.js (New) 15.98kB 15.98kB 100.0% 🚀
assets/common-*.js -3 bytes 2.61kB -0.11%
assets/vega-*.js -170 bytes 13.9kB -1.21%
assets/vega-*.js 1 bytes 595 bytes 0.17%
assets/run-*.js 2.86kB 13.49kB 26.86% ⚠️
assets/write-*.js -3.84kB 13.1kB -22.67%
assets/graphlib-*.js 3 bytes 12.64kB 0.02%
assets/tracing-*.js -1 bytes 819 bytes -0.12%
assets/tracing-*.js -90 bytes 11.37kB -0.79%
assets/app-*.js -34 bytes 11.26kB -0.3%
assets/feedback-*.js (New) 10.6kB 10.6kB 100.0% 🚀
assets/useCellActionButton-*.js -102 bytes 9.11kB -1.11%
assets/config-*.js -43 bytes 7.76kB -0.55%
assets/command-*.js 43 bytes 8.73kB 0.5%
assets/snippets-*.js -98 bytes 7.31kB -1.32%
assets/scratchpad-*.js -130 bytes 7.03kB -1.82%
assets/alert-*.js 5.05kB 7.01kB 257.16% ⚠️
assets/alert-*.js (Deleted) -12.37kB 0 bytes -100.0% 🗑️
assets/utils-*.js (Deleted) -303 bytes 0 bytes -100.0% 🗑️
assets/components-*.js -81 bytes 5.68kB -1.41%
assets/ErrorBoundary-*.js 2.95kB 6.18kB 91.51% ⚠️
assets/use-*.js 3.9kB 5.71kB 215.42% ⚠️
assets/use-*.js 1.18kB 1.81kB 188.06% ⚠️
assets/use-*.js (New) 628 bytes 628 bytes 100.0% 🚀
assets/cache-*.js -38 bytes 5.5kB -0.69%
assets/gallery-*.js -40 bytes 4.54kB -0.87%
assets/secrets-*.js -126 bytes 4.25kB -2.88%
assets/_baseMerge-*.js 7 bytes 3.18kB 0.22%
assets/logs-*.js -3 bytes 2.87kB -0.1%
assets/process-*.js -2 bytes 2.35kB -0.08%
assets/code-*.js (New) 2.06kB 2.06kB 100.0% 🚀
assets/any-*.js -39 bytes 1.92kB -1.99%
assets/error-*.js -47 bytes 1.74kB -2.64%
assets/error-*.js -1.08kB 1.86kB -36.66%
assets/documentation-*.js -4 bytes 899 bytes -0.44%
assets/state-*.js (Deleted) -808 bytes 0 bytes -100.0% 🗑️
assets/skeleton-*.js (New) 440 bytes 440 bytes 100.0% 🚀
assets/has-*.js -2 bytes 179 bytes -1.1%
assets/JsonOutput-*.js (Deleted) -581.38kB 0 bytes -100.0% 🗑️
assets/dates-*.js (Deleted) -38.6kB 0 bytes -100.0% 🗑️
assets/MarimoErrorOutput-*.js (Deleted) -30.48kB 0 bytes -100.0% 🗑️
assets/react-*.browser.esm-BL2E7f5c.js (Deleted) -25.58kB 0 bytes -100.0% 🗑️
assets/VisuallyHidden-*.js (Deleted) -18.2kB 0 bytes -100.0% 🗑️
assets/html-*.js (Deleted) -14.36kB 0 bytes -100.0% 🗑️
assets/switch-*.js (Deleted) -10.9kB 0 bytes -100.0% 🗑️
assets/download-*.js (Deleted) -9.07kB 0 bytes -100.0% 🗑️
assets/react-*.esm-C6SMwKZH.js (Deleted) -8.38kB 0 bytes -100.0% 🗑️
assets/en-*.js (Deleted) -7.24kB 0 bytes -100.0% 🗑️
assets/RenderHTML-*.js (Deleted) -6.3kB 0 bytes -100.0% 🗑️
assets/markdown-*.js (Deleted) -5.2kB 0 bytes -100.0% 🗑️
assets/tabs-*.js (Deleted) -4.88kB 0 bytes -100.0% 🗑️
assets/datasource-*.js (Deleted) -4.71kB 0 bytes -100.0% 🗑️
assets/emotion-*.esm-nLO-SoUf.js (Deleted) -4.37kB 0 bytes -100.0% 🗑️
assets/useInstallPackage-*.js (Deleted) -3.74kB 0 bytes -100.0% 🗑️
assets/table-*.js (Deleted) -3.37kB 0 bytes -100.0% 🗑️
assets/table-*.js (Deleted) -608 bytes 0 bytes -100.0% 🗑️
assets/tree-*.js (Deleted) -3.06kB 0 bytes -100.0% 🗑️
assets/cell-*.js (Deleted) -2.98kB 0 bytes -100.0% 🗑️
assets/useDateFormatter-*.js (Deleted) -2.72kB 0 bytes -100.0% 🗑️
assets/JsonOutput-*.css (Deleted) -1.32kB 0 bytes -100.0% 🗑️
assets/useRunCells-*.js (Deleted) -1.28kB 0 bytes -100.0% 🗑️
assets/spinner-*.js (Deleted) -1.04kB 0 bytes -100.0% 🗑️
assets/markdown-*.css (Deleted) -613 bytes 0 bytes -100.0% 🗑️
assets/eye-*.js (Deleted) -612 bytes 0 bytes -100.0% 🗑️
assets/hasIn-*.js (Deleted) -567 bytes 0 bytes -100.0% 🗑️
assets/kbd-*.js (Deleted) -529 bytes 0 bytes -100.0% 🗑️
assets/_baseSet-*.js (Deleted) -484 bytes 0 bytes -100.0% 🗑️
assets/_hasPath-*.js (Deleted) -322 bytes 0 bytes -100.0% 🗑️
assets/refresh-*.js (Deleted) -321 bytes 0 bytes -100.0% 🗑️
assets/formats-*.js (Deleted) -264 bytes 0 bytes -100.0% 🗑️
assets/external-*.js (Deleted) -251 bytes 0 bytes -100.0% 🗑️
assets/message-*.js (Deleted) -241 bytes 0 bytes -100.0% 🗑️
assets/extends-*.js (Deleted) -231 bytes 0 bytes -100.0% 🗑️
assets/isValid-*.js (Deleted) -231 bytes 0 bytes -100.0% 🗑️
assets/useIframeCapabilities-*.js (Deleted) -228 bytes 0 bytes -100.0% 🗑️
assets/ellipsis-*.js (Deleted) -226 bytes 0 bytes -100.0% 🗑️

@mscolnick
mscolnick merged commit 91424ca into marimo-team:main Sep 21, 2026
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ipynb → marimo conversion of %env keeps shell quotes and leaks spaces into the variable name

2 participants