A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Add option to display error tracebacks inline and in modal (#8376)
Will Lachance34f87a58bc81
diff --git a/docs/guides/deploying/index.md b/docs/guides/deploying/index.mdindex f29d4f88c9..81efe7e9c4 100644--- a/docs/guides/deploying/index.md+++ b/docs/guides/deploying/index.md@@ -60,3 +60,20 @@ You can include code in your application by using the `--include-code` flag when```bashmarimo run app.py --include-code```++### Redirecting standard output to the browser++By default, Marimo doesn't send standard output (stdout) to the browser, but for debugging purposes you can enable this+with `--redirect-console-to-browser`:++```bash+marimo run app.py --redirect-console-to-browser+```++### Showing error tracebacks in the browser++By default, Marimo redacts error tracebacks in the browser for security reasons, but you can enable showing full tracebacks with `--show-tracebacks`:++```bash+marimo run app.py --show-tracebacks+```diff --git a/frontend/src/components/editor/TracebackModalContainer.tsx b/frontend/src/components/editor/TracebackModalContainer.tsxnew file mode 100644index 0000000000..b59859a4d3--- /dev/null+++ b/frontend/src/components/editor/TracebackModalContainer.tsx@@ -0,0 +1,22 @@+/* Copyright 2024 Marimo. All rights reserved. */+import React from "react";+import { useAtom } from "jotai";+import { tracebackModalAtom } from "@/core/errors/traceback-atom";+import { TracebackModal } from "./errors/traceback-modal";++export const TracebackModalContainer: React.FC = () => {+ const [tracebackData, setTracebackData] = useAtom(tracebackModalAtom);++ if (!tracebackData) {+ return null;+ }++ return (+ <TracebackModal+ isOpen={true}+ onClose={() => setTracebackData(null)}+ traceback={tracebackData.traceback}+ errorMessage={tracebackData.errorMessage}+ />+ );+};diff --git a/frontend/src/components/editor/errors/traceback-modal.tsx b/frontend/src/components/editor/errors/traceback-modal.tsxnew file mode 100644index 0000000000..b478c86572--- /dev/null+++ b/frontend/src/components/editor/errors/traceback-modal.tsx@@ -0,0 +1,87 @@+/* Copyright 2026 Marimo. All rights reserved. */+import React from "react";+import { Button } from "@/components/ui/button";+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from "@/components/ui/alert-dialog";+import { CopyIcon } from "lucide-react";+import { toast } from "@/components/ui/use-toast";++interface TracebackModalProps {+ isOpen: boolean;+ onClose: () => void;+ traceback: string;+ errorMessage: string;+}++export const TracebackModal: React.FC<TracebackModalProps> = ({+ isOpen,+ onClose,+ traceback,+ errorMessage,+}) => {+ const handleCopy = async () => {+ // Strip HTML tags for clipboard+ const tempDiv = document.createElement("div");+ tempDiv.innerHTML = traceback;+ const textContent = tempDiv.textContent || tempDiv.innerText || "";++ try {+ await navigator.clipboard.writeText(textContent);+ toast({+ title: "Copied to clipboard",+ description: "Traceback has been copied to your clipboard.",+ });+ } catch {+ toast({+ title: "Failed to copy",+ description: "Could not copy to clipboard.",+ variant: "danger",+ });+ }+ };++ return (+ <AlertDialog open={isOpen} onOpenChange={(open) => !open && onClose()}>+ <AlertDialogContent className="max-w-4xl max-h-[80vh]">+ <AlertDialogHeader>+ <AlertDialogTitle className="text-destructive">+ {errorMessage}+ </AlertDialogTitle>+ <AlertDialogDescription>+ Click the traceback to select and copy.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <div className="my-4 overflow-auto">+ <div className="flex items-center justify-between mb-2">+ <span className="text-sm font-medium text-muted-foreground">+ Traceback+ </span>+ <Button+ variant="outline"+ size="xs"+ onClick={handleCopy}+ className="flex items-center gap-1"+ >+ <CopyIcon className="h-3 w-3" />+ Copy+ </Button>+ </div>+ <div+ className="font-code text-sm p-4 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text"+ dangerouslySetInnerHTML={{ __html: traceback }}+ />+ </div>+ <AlertDialogFooter>+ <AlertDialogAction onClick={onClose}>Close</AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ );+};diff --git a/frontend/src/components/editor/output/MarimoErrorOutput.tsx b/frontend/src/components/editor/output/MarimoErrorOutput.tsxindex c1770406db..3f8e5370e6 100644--- a/frontend/src/components/editor/output/MarimoErrorOutput.tsx+++ b/frontend/src/components/editor/output/MarimoErrorOutput.tsx@@ -477,6 +477,7 @@ export const MarimoErrorOutput = ({);}+ // All other exceptionsreturn (<li className="my-2" key={`exception-${idx}`}>{error.raising_cell == null ? (@@ -484,14 +485,33 @@ export const MarimoErrorOutput = ({<p className="text-muted-foreground">{processTextForUrls(error.msg, `exception-${idx}`)}</p>- <div className="text-muted-foreground mt-2">- See the console area for a traceback.- </div>+ {"traceback" in error && error.traceback ? (+ <div+ className="font-code text-sm mt-2 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text"+ // biome-ignore lint/security/noDangerouslySetInnerHtml: traceback from backend+ dangerouslySetInnerHTML={{+ __html: error.traceback,+ }}+ />+ ) : (+ <div className="text-muted-foreground mt-2">+ See the console area for a traceback.+ </div>+ )}</div>) : (<div>{processTextForUrls(error.msg, `exception-${idx}`)}<CellLinkError cellId={error.raising_cell} />+ {"traceback" in error && error.traceback && (+ <div+ className="font-code text-sm mt-2 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text"+ // biome-ignore lint/security/noDangerouslySetInnerHtml: traceback from backend+ dangerouslySetInnerHTML={{+ __html: error.traceback,+ }}+ />+ )}</div>)}</li>diff --git a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsxindex 1bbb805073..10e380ad88 100644--- a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx+++ b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx@@ -32,7 +32,7 @@ import type { CellData, CellRuntimeState } from "@/core/cells/types";import { MarkdownLanguageAdapter } from "@/core/codemirror/language/languages/markdown";import { useResolvedMarimoConfig } from "@/core/config/config";import { CSSClasses, KnownQueryParams } from "@/core/constants";-import type { OutputMessage } from "@/core/kernel/messages";+import type { MarimoError, OutputMessage } from "@/core/kernel/messages";import { kernelStateAtom } from "@/core/kernel/state";import { showCodeInRunModeAtom } from "@/core/meta/state";import { isErrorMime } from "@/core/mime";@@ -121,6 +121,7 @@ const VerticalLayoutRenderer: React.FC<VerticalLayoutProps> = ({staleInputs={cell.staleInputs}name={cell.name}kiosk={kioskMode}+ showErrorTracebacks={userConfig.runtime.show_tracebacks ?? false}/>);};@@ -330,6 +331,7 @@ interface VerticalCellProps extends Pick<showCode: boolean;name: string;kiosk: boolean;+ showErrorTracebacks: boolean;}const VerticalCell = memo(@@ -350,6 +352,7 @@ const VerticalCell = memo(mode,name,kiosk,+ showErrorTracebacks,}: VerticalCellProps) => {const cellRef = useRef<HTMLDivElement>(null);@@ -427,7 +430,18 @@ const VerticalCell = memo(}const outputIsError = isErrorMime(output?.mimetype);- const hidden = errored || interrupted || stopped || outputIsError;+ // When show_tracebacks is enabled, show error outputs inline+ // instead of hiding them+ const hasTraceback =+ showErrorTracebacks &&+ outputIsError &&+ Array.isArray(output?.data) &&+ output.data.some(+ (e: MarimoError) =>+ e.type === "exception" && "traceback" in e && e.traceback,+ );+ const hidden =+ (errored || interrupted || stopped || outputIsError) && !hasTraceback;if (hidden) {return null;}diff --git a/frontend/src/components/ui/toast.tsx b/frontend/src/components/ui/toast.tsxindex 70bfe5fca8..ea2a62d1a6 100644--- a/frontend/src/components/ui/toast.tsx+++ b/frontend/src/components/ui/toast.tsx@@ -118,7 +118,9 @@ ToastDescription.displayName = ToastPrimitives.Description.displayName;type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;-type ToastActionElement = React.ReactElement<typeof ToastAction>;+type ToastActionElement = React.ReactElement<+ React.ComponentProps<typeof ToastAction>+>;export {type ToastProps,diff --git a/frontend/src/core/MarimoApp.tsx b/frontend/src/core/MarimoApp.tsxindex 751e1588f0..cdd6edd936 100644--- a/frontend/src/core/MarimoApp.tsx+++ b/frontend/src/core/MarimoApp.tsx@@ -13,6 +13,7 @@ import { CssVariables } from "@/theme/ThemeProvider";import { reactLazyWithPreload } from "@/utils/lazy";import { ErrorBoundary } from "../components/editor/boundary/ErrorBoundary";import { KernelStartupErrorModal } from "../components/editor/KernelStartupErrorModal";+import { TracebackModalContainer } from "../components/editor/TracebackModalContainer";import { ModalProvider } from "../components/modal/ImperativeModal";import { Toaster } from "../components/ui/toaster";import { TooltipProvider } from "../components/ui/tooltip";@@ -105,6 +106,7 @@ const Providers = memo(({ children }: PropsWithChildren) => {<Toaster /><TailwindIndicator /><KernelStartupErrorModal />+ <TracebackModalContainer /></ModalProvider></LocaleProvider></SlotzProvider>diff --git a/frontend/src/core/cells/logs.ts b/frontend/src/core/cells/logs.tsindex 0413558db1..e877d722e2 100644--- a/frontend/src/core/cells/logs.ts+++ b/frontend/src/core/cells/logs.ts@@ -7,6 +7,10 @@ import { Strings } from "@/utils/strings";import type { CellMessage, OutputMessage } from "../kernel/messages";import { isErrorMime } from "../mime";import type { CellId } from "./ids";+import { store } from "../state/jotai";+import { tracebackModalAtom } from "../errors/traceback-atom";+import React from "react";+import { ToastAction } from "@/components/ui/toast";export interface CellLog {timestamp: number;@@ -72,17 +76,52 @@ export function getCellLogsForMessage(cell: CellMessage): CellLog[] {});});- const shouldToast = cell.output.data.some(- (error) => error.type === "internal",+ // Find exception errors and check for traceback+ const exceptionErrors = cell.output.data.filter(+ (error) =>+ ("type" in error && error.type === "exception") ||+ error.type === "internal",);- if (!didAlreadyToastError && shouldToast) {++ if (exceptionErrors.length > 0 && !didAlreadyToastError) {didAlreadyToastError = true;- toast({- title: "An internal error occurred",- description: "See console for details.",- className:- "text-xs text-background bg-(--red-10) py-2 pl-3 *:flex *:gap-3",- });++ // Find first error with a traceback+ const errorWithTraceback = exceptionErrors.find(+ (error) => error.traceback,+ );++ if (errorWithTraceback) {+ // Show toast with action button to open modal+ const handleClick = () => {+ store.set(tracebackModalAtom, {+ traceback: errorWithTraceback.traceback,+ errorMessage:+ errorWithTraceback.msg || "An internal error occurred",+ });+ };++ toast({+ title: "An internal error occurred",+ description:+ errorWithTraceback.msg || "Click 'View' to see traceback",+ variant: "danger",+ action: React.createElement(+ ToastAction,+ {+ altText: "View traceback",+ onClick: handleClick,+ },+ "View",+ ),+ });+ } else {+ toast({+ title: "An internal error occurred",+ description: "See console for details.",+ variant: "danger",+ });+ }}}diff --git a/frontend/src/core/config/__tests__/config-schema.test.ts b/frontend/src/core/config/__tests__/config-schema.test.tsindex 3109bd4a0a..dfb5e63880 100644--- a/frontend/src/core/config/__tests__/config-schema.test.ts+++ b/frontend/src/core/config/__tests__/config-schema.test.ts@@ -90,6 +90,7 @@ test("default UserConfig - empty", () => {"default_sql_output": "auto","on_cell_change": "autorun","reactive_tests": true,+ "show_tracebacks": false,"watcher_on_save": "lazy",},"save": {@@ -160,6 +161,7 @@ test("default UserConfig - one level", () => {"default_sql_output": "auto","on_cell_change": "autorun","reactive_tests": true,+ "show_tracebacks": false,"watcher_on_save": "lazy",},"save": {diff --git a/frontend/src/core/config/config-schema.ts b/frontend/src/core/config/config-schema.tsindex 956d627c85..595be39646 100644--- a/frontend/src/core/config/config-schema.ts+++ b/frontend/src/core/config/config-schema.ts@@ -126,6 +126,7 @@ export const UserConfigSchema = zdefault_auto_download: z.array(z.enum(AUTO_DOWNLOAD_FORMATS)).prefault([]),+ show_tracebacks: z.boolean().prefault(false),}).prefault({}),display: zdiff --git a/frontend/src/core/errors/traceback-atom.ts b/frontend/src/core/errors/traceback-atom.tsnew file mode 100644index 0000000000..15122ce99d--- /dev/null+++ b/frontend/src/core/errors/traceback-atom.ts@@ -0,0 +1,9 @@+/* Copyright 2026 Marimo. All rights reserved. */+import { atom } from "jotai";++export interface TracebackData {+ traceback: string;+ errorMessage: string;+}++export const tracebackModalAtom = atom<TracebackData | null>(null);diff --git a/marimo/_cli/cli.py b/marimo/_cli/cli.pyindex e637991c37..62c75bce50 100644--- a/marimo/_cli/cli.py+++ b/marimo/_cli/cli.py@@ -1074,6 +1074,13 @@ Example:hidden=True,help="Custom asset URL for loading static resources. Can include {version} placeholder.",)+ "--show-tracebacks/--no-show-tracebacks",+ is_flag=True,+ default=None,+ type=bool,+ help="Show detailed error tracebacks in a modal when exceptions occur.",+)@click.pass_context@click.argument("name",@@ -1102,6 +1109,7 @@ def run(trusted: Optional[bool],server_startup_command: Optional[str],asset_url: Optional[str],+ show_tracebacks: Optional[bool],name: str,args: tuple[str, ...],) -> None:@@ -1231,6 +1239,7 @@ def run(asset_url=asset_url,sandbox_mode=sandbox_mode,startup_tip=choose_startup_tip(click.get_current_context()),+ show_tracebacks=show_tracebacks,)diff --git a/marimo/_config/config.py b/marimo/_config/config.pyindex 03d8b327c7..e56665bb1d 100644--- a/marimo/_config/config.py+++ b/marimo/_config/config.py@@ -171,6 +171,9 @@ class RuntimeConfig(TypedDict):The default is None.- `default_csv_encoding`: the default encoding for CSV exports.The default is `"utf-8"`.+ - `show_tracebacks`: if `True`, show detailed error tracebacks in run mode.+ When enabled, exceptions will display a clickable toast that opens a modal with the full traceback.+ The default is `False`."""auto_instantiate: bool@@ -186,6 +189,7 @@ class RuntimeConfig(TypedDict):default_sql_output: SqlOutputTypedefault_auto_download: NotRequired[list[ExportType]]default_csv_encoding: NotRequired[str]+ show_tracebacks: NotRequired[bool]@mddoc@@ -728,6 +732,7 @@ DEFAULT_CONFIG: MarimoConfig = {),"default_sql_output": "auto","default_csv_encoding": "utf-8",+ "show_tracebacks": False,},"save": {"autosave": "after_delay",diff --git a/marimo/_messaging/errors.py b/marimo/_messaging/errors.pyindex 0e88279952..c61d1faf62 100644--- a/marimo/_messaging/errors.py+++ b/marimo/_messaging/errors.py@@ -66,6 +66,8 @@ class MarimoExceptionRaisedError(msgspec.Struct, tag="exception"):exception_type: str# None for if raising_cell is the current cellraising_cell: Optional[CellId_t]+ # Formatted traceback HTML (optional, for displaying full stacktrace)+ traceback: Optional[str] = Nonedef describe(self) -> str:return self.msgdiff --git a/marimo/_messaging/notification_utils.py b/marimo/_messaging/notification_utils.pyindex 4541079f1e..da80515675 100644--- a/marimo/_messaging/notification_utils.py+++ b/marimo/_messaging/notification_utils.py@@ -13,6 +13,7 @@ from uuid import uuid4from marimo import _loggers as loggersfrom marimo._messaging.cell_output import CellOutputfrom marimo._messaging.errors import (+ MarimoExceptionRaisedError,MarimoInternalError,is_sensitive_error,)@@ -227,12 +228,31 @@ class CellNotificationUtils:# and then broadcast a new error such that the data is hidden.safe_errors: list[Error] = []if get_mode() == "run":+ # Check if show_tracebacks is enabled+ show_tracebacks = False+ try:+ ctx = get_context()+ show_tracebacks = bool(+ ctx.marimo_config["runtime"].get("show_tracebacks", False)+ )+ except ContextNotInitializedError:+ pass+for error in data:# Skip non-sensitive errorsif not is_sensitive_error(error):safe_errors.append(error)continue+ # show raised exceptions only if `show_tracebacks` is enabled+ if (+ isinstance(error, MarimoExceptionRaisedError)+ and show_tracebacks+ ):+ safe_errors.append(error)+ continue++ # Sanitize sensitive errorserror_id = uuid4()LOGGER.error(f"(error_id={error_id}) {error.describe()}",diff --git a/marimo/_messaging/tracebacks.py b/marimo/_messaging/tracebacks.pyindex 5a86eeda78..0afc36d68f 100644--- a/marimo/_messaging/tracebacks.py+++ b/marimo/_messaging/tracebacks.py@@ -3,8 +3,13 @@ from __future__ import annotationsimport sys+from marimo._messaging.cell_output import CellChannel, CellOutputfrom marimo._messaging.context import is_code_mode_request+from marimo._messaging.notification import CellNotification+from marimo._messaging.notification_utils import broadcast_notificationfrom marimo._messaging.types import Stderr+from marimo._runtime.context.types import safe_get_context+from marimo._runtime.context.utils import get_modedef _highlight_traceback(traceback: str) -> str:@@ -22,8 +27,27 @@ def _highlight_traceback(traceback: str) -> str:return f'<span class="codehilite">{body}</span>'+def _show_tracebacks_enabled() -> bool:+ """Returns True if show_tracebacks is enabled in the current config."""+ from marimo._runtime.context.types import (+ ContextNotInitializedError,+ get_context,+ )++ try:+ ctx = get_context()+ return bool(ctx.marimo_config["runtime"].get("show_tracebacks", False))+ except ContextNotInitializedError:+ return True # no context → not in run mode, always show++def write_traceback(traceback: str) -> None:+ in_run_mode = get_mode() == "run"+if isinstance(sys.stderr, Stderr) and not is_code_mode_request():+ # In run mode, only forward to the frontend if show_tracebacks is on.+ if in_run_mode and not _show_tracebacks_enabled():+ return# Strip marimo's internal executor.py frame and highlight for the UItrimmed = _trim_traceback(traceback)sys.stderr._write_with_mimetype(@@ -31,7 +55,28 @@ def write_traceback(traceback: str) -> None:mimetype="application/vnd.marimo+traceback",)else:- sys.stderr.write(traceback)+ # When stderr is not redirected (e.g., run mode with redirect_console_to_browser=False),+ # send the traceback directly via the stream to ensure exceptions reach the frontend+ ctx = safe_get_context()+ if ctx is not None and ctx.cell_id is not None:+ # In run mode, only forward to the frontend if show_tracebacks is on.+ if in_run_mode and not _show_tracebacks_enabled():+ sys.stderr.write(traceback)+ return+ broadcast_notification(+ CellNotification(+ cell_id=ctx.cell_id,+ console=CellOutput(+ channel=CellChannel.STDERR,+ mimetype="application/vnd.marimo+traceback",+ data=_highlight_traceback(_trim_traceback(traceback)),+ ),+ ),+ ctx.stream,+ )+ else:+ # Fallback to regular stderr if no context is available+ sys.stderr.write(traceback)def _trim_traceback(traceback: str) -> str:diff --git a/marimo/_runtime/runner/cell_runner.py b/marimo/_runtime/runner/cell_runner.pyindex 65a851135a..6ede07d508 100644--- a/marimo/_runtime/runner/cell_runner.py+++ b/marimo/_runtime/runner/cell_runner.py@@ -15,7 +15,7 @@ from types import TracebackTypefrom typing import TYPE_CHECKING, Any, Optionalfrom marimo._ast.variables import unmangle_local-from marimo._config.config import ExecutionType, OnCellChangeType+from marimo._config.config import ExecutionType, MarimoConfig, OnCellChangeTypefrom marimo._dependencies.dependencies import DependencyManagerfrom marimo._dependencies.errors import ManyModulesNotFoundErrorfrom marimo._loggers import marimo_logger@@ -135,6 +135,7 @@ class Runner:execution_type: ExecutionType = "relaxed",excluded_cells: set[CellId_t] | None = None,execution_context: ExecutionContextManager | None = None,+ user_config: MarimoConfig | None = None,):self.graph = graphself.debugger = debugger@@ -144,6 +145,7 @@ class Runner:)self.execution_context = execution_contextself._hooks = hooks+ self.user_config = user_config# runtime globalsself.glbls = glbls@@ -719,6 +721,7 @@ class Runner:cancelled_cells=self.cancelled_cells,all_temporaries=all_temporaries,should_broadcast_data=_should_broadcast_data(),+ user_config=self.user_config,)while self.pending():diff --git a/marimo/_runtime/runner/hook_context.py b/marimo/_runtime/runner/hook_context.pyindex 8dc10d8af4..1e07f03d85 100644--- a/marimo/_runtime/runner/hook_context.py+++ b/marimo/_runtime/runner/hook_context.py@@ -4,7 +4,7 @@ from __future__ import annotationsfrom dataclasses import dataclassfrom typing import TYPE_CHECKING, Any, Callable, TypeAlias, Union-from marimo._config.config import OnCellChangeType+from marimo._config.config import MarimoConfig, OnCellChangeTypefrom marimo._messaging.errors import Errorfrom marimo._types.ids import CellId_t@@ -83,6 +83,8 @@ class PostExecutionHookContext:# Whether data (variables, datasets, etc.) should be broadcast# to the frontend. Computed once per run to avoid repeated checks.should_broadcast_data: bool = False+ # User configuration, for hooks that need access to runtime settings+ user_config: MarimoConfig | None = None@dataclass(frozen=True)diff --git a/marimo/_runtime/runner/hooks_post_execution.py b/marimo/_runtime/runner/hooks_post_execution.pyindex a4c237b21c..cf6c8e7e20 100644--- a/marimo/_runtime/runner/hooks_post_execution.py+++ b/marimo/_runtime/runner/hooks_post_execution.py@@ -2,6 +2,7 @@from __future__ import annotationsimport sys+import traceback as tbfrom marimo import _loggersfrom marimo._ast.cell import CellImpl@@ -32,7 +33,11 @@ from marimo._messaging.notification_utils import (CellNotificationUtils,broadcast_notification,)-from marimo._messaging.tracebacks import write_traceback+from marimo._messaging.tracebacks import (+ _highlight_traceback,+ _trim_traceback,+ write_traceback,+)from marimo._messaging.variables import create_variable_valuefrom marimo._output import formattingfrom marimo._plugins.ui._core.ui_element import UIElement@@ -407,12 +412,32 @@ def _broadcast_outputs(msg = str(run_result.exception)if not msg:msg = f"This cell raised an exception: {exception_type}"++ # Include formatted traceback if enabled in config+ formatted_traceback = None+ show_tracebacks = False+ if ctx.user_config is not None:+ show_tracebacks = bool(+ ctx.user_config["runtime"].get("show_tracebacks", False)+ )++ if show_tracebacks:+ if (+ isinstance(run_result.exception, BaseException)+ and run_result.exception.__traceback__+ ):+ tb_lines = tb.format_exception(run_result.exception)+ formatted_traceback = _highlight_traceback(+ _trim_traceback("".join(tb_lines))+ )+CellNotificationUtils.broadcast_error(data=[MarimoExceptionRaisedError(msg=msg,exception_type=exception_type,raising_cell=None,+ traceback=formatted_traceback,)],clear_console=False,diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.pyindex 83d7bb24b5..b05dfb6777 100644--- a/marimo/_runtime/runtime.py+++ b/marimo/_runtime/runtime.py@@ -1477,6 +1477,7 @@ class Kernel:execution_type=self.execution_type,execution_context=self._install_execution_context,hooks=run_hooks,+ user_config=self.user_config,)# I/O@@ -1779,6 +1780,7 @@ class Kernel:execution_type=self.execution_type,execution_context=self._install_execution_context,hooks=scratchpad_hooks,+ user_config=self.user_config,)await runner.run_all()diff --git a/marimo/_server/asgi.py b/marimo/_server/asgi.pyindex 7d18df997a..6b945a7b6b 100644--- a/marimo/_server/asgi.py+++ b/marimo/_server/asgi.py@@ -13,6 +13,7 @@ from typing import (Optional,Protocol,Union,+ cast,)if TYPE_CHECKING:@@ -340,6 +341,7 @@ def create_asgi_app(session_ttl: int = 120,asset_url: Optional[str] = None,redirect_console_to_browser: bool = False,+ show_tracebacks: bool = False,html_head: Optional[str] = None,) -> ASGIAppBuilder:"""Public API to create an ASGI app that can serve multiple notebooks.@@ -357,6 +359,8 @@ def create_asgi_app(e.g. https://cdn.jsdelivr.net/npm/@marimo-team/frontend@{version}/distredirect_console_to_browser (bool, optional): Whether to redirect console output (stdout/stderr) to the browser.When True, console output will be displayed in the browser. Defaults to False.+ show_tracebacks (bool, optional): Whether to show detailed error tracebacks in a modal.+ When True, exceptions will display a clickable toast that opens a modal with the full traceback. Defaults to False.html_head (str, optional): Custom HTML string to inject into the <head> of every notebook page.This is useful for adding global analytics scripts, custom stylesheets, meta tags, etc.When a notebook also has its own `html_head_file` config, the global `html_head` is injected first,@@ -437,6 +441,7 @@ def create_asgi_app(from starlette.responses import RedirectResponseimport marimo._server.api.lifespans as lifespans+ from marimo._config.config import PartialMarimoConfigfrom marimo._config.manager import get_default_config_managerfrom marimo._server.file_router import AppFileRouterfrom marimo._server.lsp import NoopLspServer@@ -510,6 +515,14 @@ def create_asgi_app(@staticmethoddef _create_app_for_file(base_url: str, file_path: str) -> ASGIApp:+ # Apply runtime config override for show_tracebacks+ app_config_reader = config_reader.with_overrides(+ cast(+ PartialMarimoConfig,+ {"runtime": {"show_tracebacks": show_tracebacks}},+ )+ )+session_manager = SessionManager(file_router=AppFileRouter.from_filename(MarimoPath(file_path)),mode=SessionMode.RUN,@@ -518,7 +531,7 @@ def create_asgi_app(# Currently we only support run mode,# which doesn't require an LSP serverlsp_server=NoopLspServer(),- config_manager=config_reader,+ config_manager=app_config_reader,# We don't pass any CLI args for now# since we don't want to read arbitrary args and apply them# to each application@@ -549,7 +562,7 @@ def create_asgi_app(app.state.session_manager = session_managerapp.state.base_url = base_urlapp.state.asset_url = asset_url- app.state.config_manager = config_reader+ app.state.config_manager = app_config_readerapp.state.enable_auth = enable_authapp.state.html_head = html_headreturn appdiff --git a/marimo/_server/start.py b/marimo/_server/start.pyindex 19a358ae51..4a3c478f3d 100644--- a/marimo/_server/start.py+++ b/marimo/_server/start.py@@ -5,12 +5,13 @@ import osimport reimport subprocessimport threading-from typing import TYPE_CHECKING, Optional+from typing import TYPE_CHECKING, Optional, castimport uvicornfrom marimo._cli.print import echofrom marimo._cli.sandbox import SandboxMode+from marimo._config.config import PartialMarimoConfigfrom marimo._config.manager import get_default_config_managerfrom marimo._config.settings import GLOBAL_SETTINGSfrom marimo._mcp.setup import McpType, setup_mcp_server@@ -187,6 +188,7 @@ def start(timeout: Optional[float] = None,sandbox_mode: SandboxMode | None = None,startup_tip: CliTip | None = None,+ show_tracebacks: Optional[bool] = None,) -> None:"""Start the server.@@ -257,6 +259,15 @@ def start("isolate_apps", False)+ # Apply CLI overrides for runtime config if explicitly set+ if show_tracebacks is not None:+ config_reader = config_reader.with_overrides(+ cast(+ PartialMarimoConfig,+ {"runtime": {"show_tracebacks": show_tracebacks}},+ )+ )+session_manager = SessionManager(file_router=file_router,mode=mode,diff --git a/packages/openapi/api.yaml b/packages/openapi/api.yamlindex 173ed24351..fe967f1333 100644--- a/packages/openapi/api.yaml+++ b/packages/openapi/api.yaml@@ -3064,6 +3064,11 @@ components:anyOf:- $ref: '#/components/schemas/CellId'- type: 'null'+ traceback:+ anyOf:+ - type: string+ - type: 'null'+ default: nulltype:enum:- exception@@ -4035,7 +4040,10 @@ components:\ is `\"auto\"`.\n - `default_auto_download`: an Optional list of export\\ types to automatically snapshot your notebook as:\n `html`, `markdown`,\\ `ipynb`.\n The default is None.\n - `default_csv_encoding`: the\- \ default encoding for CSV exports.\n The default is `\"utf-8\"`."+ \ default encoding for CSV exports.\n The default is `\"utf-8\"`.\n\+ \ - `show_tracebacks`: if `True`, show detailed error tracebacks in run\+ \ mode.\n When enabled, exceptions will display a clickable toast that\+ \ opens a modal with the full traceback.\n The default is `False`."properties:auto_instantiate:type: boolean@@ -4078,6 +4086,8 @@ components:type: booleanserve_cached_sessions_in_apps:type: boolean+ show_tracebacks:+ type: booleanstd_stream_max_bytes:type: integerwatcher_on_save:diff --git a/packages/openapi/src/api.ts b/packages/openapi/src/api.tsindex 65239a2320..2c33344d56 100644--- a/packages/openapi/src/api.ts+++ b/packages/openapi/src/api.ts@@ -5155,6 +5155,8 @@ export interface components {exception_type: string;msg: string;raising_cell: components["schemas"]["CellId"] | null;+ /** @default null */+ traceback?: string | null;/** @enum {unknown} */type: "exception";};@@ -5773,6 +5775,9 @@ export interface components {* The default is None.* - `default_csv_encoding`: the default encoding for CSV exports.* The default is `"utf-8"`.+ * - `show_tracebacks`: if `True`, show detailed error tracebacks in run mode.+ * When enabled, exceptions will display a clickable toast that opens a modal with the full traceback.+ * The default is `False`.*/RuntimeConfig: {auto_instantiate: boolean;@@ -5794,6 +5799,7 @@ export interface components {pythonpath?: string[];reactive_tests: boolean;serve_cached_sessions_in_apps?: boolean;+ show_tracebacks?: boolean;std_stream_max_bytes: number;/** @enum {unknown} */watcher_on_save: "autorun" | "lazy";diff --git a/tests/_messaging/test_tracebacks.py b/tests/_messaging/test_tracebacks.pyindex 8b72d0f7f8..ddd4fe4350 100644--- a/tests/_messaging/test_tracebacks.py+++ b/tests/_messaging/test_tracebacks.py@@ -129,6 +129,43 @@ class TestTracebacks:finally:HTTP_REQUEST_CTX.reset(token)+ def test_write_traceback_suppressed_in_run_mode(self) -> None:+ """In run mode with show_tracebacks=False, nothing is sent to the frontend."""+ mock_stderr = MagicMock(spec=Stderr)+ with (+ patch("sys.stderr", mock_stderr),+ patch("marimo._messaging.tracebacks.get_mode", return_value="run"),+ patch(+ "marimo._messaging.tracebacks._show_tracebacks_enabled",+ return_value=False,+ ),+ ):+ write_traceback(+ 'Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\nRuntimeError: secret'+ )+ mock_stderr._write_with_mimetype.assert_not_called()+ mock_stderr.write.assert_not_called()++ def test_write_traceback_forwarded_in_run_mode_with_show_tracebacks(+ self,+ ) -> None:+ """In run mode with show_tracebacks=True, traceback is sent to the frontend."""+ mock_stderr = MagicMock(spec=Stderr)+ with (+ patch("sys.stderr", mock_stderr),+ patch("marimo._messaging.tracebacks.get_mode", return_value="run"),+ patch(+ "marimo._messaging.tracebacks._show_tracebacks_enabled",+ return_value=True,+ ),+ ):+ write_traceback(+ 'Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\nRuntimeError: visible'+ )+ mock_stderr._write_with_mimetype.assert_called_once()+ _, kwargs = mock_stderr._write_with_mimetype.call_args+ assert kwargs["mimetype"] == "application/vnd.marimo+traceback"+class TestIsCodeModeRequest:def test_no_request_context(self) -> None:diff --git a/tests/_runtime/test_runtime.py b/tests/_runtime/test_runtime.pyindex 8fe7cbb1c4..903b0ba882 100644--- a/tests/_runtime/test_runtime.py+++ b/tests/_runtime/test_runtime.py@@ -2,6 +2,7 @@from __future__ import annotationsimport asyncio+import copyimport pathlibimport sysimport textwrap@@ -3701,6 +3702,40 @@ class TestErrorHandling:assert isinstance(errors[0], MarimoInternalError)assert errors[0].msg.startswith("An internal error occurred: ")+ # Verify no traceback leaks via console output+ for op in cell_notifications:+ if op.console is not None:+ console_list = (+ [op.console]+ if not isinstance(op.console, list)+ else op.console+ )+ for console_output in console_list:+ assert "some secret error" not in str(+ console_output.data+ ), "Traceback leaked to console in run mode"++ async def test_error_handling_in_run_mode_with_show_tracebacks(+ self, run_mode_kernel: MockedKernel, exec_req: ExecReqProvider+ ) -> None:+ """When show_tracebacks is enabled, exceptions should not be+ sanitized and should include a formatted traceback."""+ k = run_mode_kernel.k+ k.user_config = copy.deepcopy(k.user_config)+ k.user_config["runtime"]["show_tracebacks"] = True+ await k.run([exec_req.get("raise ValueError('some secret error')")])+ cell_notifications = run_mode_kernel.stream.cell_notifications+ error_cell_notification = _filter_to_error_ops(cell_notifications)+ assert len(error_cell_notification) == 1+ errors = _parse_error_output(error_cell_notification[0])++ assert len(errors) == 1+ assert isinstance(errors[0], MarimoExceptionRaisedError)+ assert errors[0].msg == "some secret error"+ assert errors[0].exception_type == "ValueError"+ assert errors[0].traceback is not None+ assert "ValueError" in errors[0].traceback+async def test_error_handling_in_run_mode_stop(self, run_mode_kernel: MockedKernel, exec_req: ExecReqProvider) -> None:diff --git a/tests/_runtime/test_trace.py b/tests/_runtime/test_trace.pyindex 5d198f6359..df1c6fa36a 100644--- a/tests/_runtime/test_trace.py+++ b/tests/_runtime/test_trace.py@@ -1,6 +1,7 @@# Copyright 2026 Marimo. All rights reserved.from __future__ import annotations+import copyimport osimport reimport subprocess@@ -331,6 +332,9 @@ class TestRunModeTrace:k = run_mode_kernel.kk.app_metadata.filename = str(notebook_file)+ k.user_config = copy.deepcopy(k.user_config)+ k.user_config["runtime"]["show_tracebacks"] = True+cell_code = textwrap.dedent("""x = 1diff --git a/tests/_server/export/snapshots/run_until_completion_with_stack_trace.txt b/tests/_server/export/snapshots/run_until_completion_with_stack_trace.txtindex 5fe3ef520c..9611ed5d45 100644--- a/tests/_server/export/snapshots/run_until_completion_with_stack_trace.txt+++ b/tests/_server/export/snapshots/run_until_completion_with_stack_trace.txt@@ -19,7 +19,8 @@"type": "exception","msg": "Failed to authenticate. The correct password is 's3cret'.","exception_type": "ValueError",- "raising_cell": null+ "raising_cell": null,+ "traceback": null}],"console": [diff --git a/tests/_server/templates/snapshots/export1.txt b/tests/_server/templates/snapshots/export1.txtindex 6b541e08ac..37b4249334 100644--- a/tests/_server/templates/snapshots/export1.txt+++ b/tests/_server/templates/snapshots/export1.txt@@ -84,7 +84,7 @@"mode": "read","version": "0.0.0","serverToken": "token",- "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},+ "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "show_tracebacks": false, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},"configOverrides": {"formatting": {"line_length": 100}},"appConfig": {"sql_output": "auto", "width": "compact"},"view": {"showAppCode": true},diff --git a/tests/_server/templates/snapshots/export2.txt b/tests/_server/templates/snapshots/export2.txtindex c44c81f2c8..f486bcb84e 100644--- a/tests/_server/templates/snapshots/export2.txt+++ b/tests/_server/templates/snapshots/export2.txt@@ -84,7 +84,7 @@"mode": "read","version": "0.0.0","serverToken": "token",- "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},+ "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "show_tracebacks": false, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},"configOverrides": {"formatting": {"line_length": 100}},"appConfig": {"sql_output": "auto", "width": "compact"},"view": {"showAppCode": true},diff --git a/tests/_server/templates/snapshots/export3.txt b/tests/_server/templates/snapshots/export3.txtindex 4442b974b9..173e75dccb 100644--- a/tests/_server/templates/snapshots/export3.txt+++ b/tests/_server/templates/snapshots/export3.txt@@ -84,7 +84,7 @@"mode": "read","version": "0.0.0","serverToken": "token",- "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},+ "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "show_tracebacks": false, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},"configOverrides": {"formatting": {"line_length": 100}},"appConfig": {"sql_output": "auto", "width": "compact"},"view": {"showAppCode": true},diff --git a/tests/_server/templates/snapshots/export4.txt b/tests/_server/templates/snapshots/export4.txtindex 6101524ce3..f2bc425d49 100644--- a/tests/_server/templates/snapshots/export4.txt+++ b/tests/_server/templates/snapshots/export4.txt@@ -84,7 +84,7 @@"mode": "read","version": "0.0.0","serverToken": "token",- "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},+ "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "show_tracebacks": false, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},"configOverrides": {"formatting": {"line_length": 100}},"appConfig": {"css_file": "custom.css", "sql_output": "auto", "width": "compact"},"view": {"showAppCode": true},diff --git a/tests/_server/templates/snapshots/export5.txt b/tests/_server/templates/snapshots/export5.txtindex 6838c27a15..6774f9dc3b 100644--- a/tests/_server/templates/snapshots/export5.txt+++ b/tests/_server/templates/snapshots/export5.txt@@ -96,7 +96,7 @@"mode": "read","version": "0.0.0","serverToken": "token",- "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},+ "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "show_tracebacks": false, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},"configOverrides": {"formatting": {"line_length": 100}},"appConfig": {"app_title": "My App", "html_head_file": "head.html", "sql_output": "auto", "width": "compact"},"view": {"showAppCode": true},diff --git a/tests/_server/templates/snapshots/export6.txt b/tests/_server/templates/snapshots/export6.txtindex 48836e2678..c647ba967b 100644--- a/tests/_server/templates/snapshots/export6.txt+++ b/tests/_server/templates/snapshots/export6.txt@@ -85,7 +85,7 @@"mode": "read","version": "0.0.0","serverToken": "token",- "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "custom_css": ["custom1.css", "custom2.css"], "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},+ "config": {"ai": {"custom_providers": {}, "models": {"custom_models": [], "displayed_models": []}}, "completion": {"activate_on_typing": true, "copilot": false, "signature_hint_on_typing": false}, "diagnostics": {"sql_linter": true}, "display": {"cell_output": "below", "code_editor_font_size": 14, "custom_css": ["custom1.css", "custom2.css"], "dataframes": "rich", "default_table_max_columns": 50, "default_table_page_size": 10, "default_width": "medium", "reference_highlighting": true, "theme": "light"}, "formatting": {"line_length": 79}, "keymap": {"overrides": {}, "preset": "default"}, "language_servers": {"pylsp": {"enable_flake8": false, "enable_mypy": true, "enable_pydocstyle": false, "enable_pyflakes": false, "enable_pylint": false, "enable_ruff": true, "enabled": false}}, "mcp": {"mcpServers": {}, "presets": []}, "package_management": {"manager": "uv"}, "runtime": {"auto_instantiate": false, "auto_reload": "off", "default_csv_encoding": "utf-8", "default_sql_output": "auto", "on_cell_change": "autorun", "output_max_bytes": 8000000, "reactive_tests": true, "show_tracebacks": false, "std_stream_max_bytes": 1000000, "watcher_on_save": "lazy"}, "save": {"autosave": "after_delay", "autosave_delay": 1000, "format_on_save": false}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}},"configOverrides": {"formatting": {"line_length": 100}},"appConfig": {"sql_output": "auto", "width": "compact"},"view": {"showAppCode": true},diff --git a/tests/_session/state/snapshots/mixed_error_session.json b/tests/_session/state/snapshots/mixed_error_session.jsonindex 711dcc6edd..3b26415f39 100644--- a/tests/_session/state/snapshots/mixed_error_session.json+++ b/tests/_session/state/snapshots/mixed_error_session.json@@ -13,7 +13,7 @@"type": "error","ename": "exception","evalue": "Invalid value",- "traceback": []+ "traceback": null},{"type": "error",diff --git a/tests/_session/state/test_serialize_session.py b/tests/_session/state/test_serialize_session.pyindex 0054482601..91058d9376 100644--- a/tests/_session/state/test_serialize_session.py+++ b/tests/_session/state/test_serialize_session.py@@ -782,6 +782,7 @@ def test_serialize_session_with_mixed_error_formats(session_view: SessionView):"exception_type": "ValueError","msg": "Invalid value","raising_cell": "cell1",+ "traceback": None,},# Object format errorUnknownError(msg="Runtime error occurred", error_type="RuntimeError"),@@ -804,12 +805,12 @@ def test_serialize_session_with_mixed_error_formats(session_view: SessionView):cell = result["cells"][0]assert len(cell["outputs"]) == 2- # Check first error (dictionary with traceback)+ # Check first error (dictionary with explicit no traceback)error1 = cell["outputs"][0]assert error1["type"] == "error"assert error1["ename"] == "exception"assert error1["evalue"] == "Invalid value"- assert error1["traceback"] == []+ assert error1["traceback"] is None# Check second error (object format)error2 = cell["outputs"][1]