streamlit/streamlit · error · StreamlitAPIException
Dialogs may not be nested inside other dialogs.
Error message
Dialogs may not be nested inside other dialogs.
What it means
Error "Dialogs may not be nested inside other dialogs." thrown in streamlit/streamlit.
Source
Thrown at lib/streamlit/elements/dialog_decorator.py:56
as this populates the dg_stack in delta_generator correctly.
This does not detect the edge case in which someone calls, for example,
`with st.sidebar` inside of a dialog function and opens a dialog in there, as
`with st.sidebar` pushes the new DeltaGenerator to the stack. In order to check for
that edge case, we could try to check all DeltaGenerators in the stack, and not only
the last one. Since we deem this to be an edge case, we lean towards simplicity
here.
Raises
------
StreamlitAPIException
Raised if the user tries to nest dialogs inside of each other.
"""
last_dg_in_current_context = get_last_dg_added_to_context_stack()
if last_dg_in_current_context and "dialog" in set(
last_dg_in_current_context._ancestor_block_types
):
raise StreamlitAPIException("Dialogs may not be nested inside other dialogs.")
F = TypeVar("F", bound=Callable[..., Any])
def _dialog_decorator(
non_optional_func: F,
title: str,
*,
width: DialogWidth = "small",
dismissible: bool = True,
icon: str | None = None,
on_dismiss: Literal["ignore", "rerun"] | WidgetCallback = "ignore",
) -> F:
if title is None or title == "":
raise StreamlitAPIException(
"A non-empty `title` argument has to be provided for dialogs, for example "
'`@st.dialog("Example Title")`.'View on GitHub (pinned to 202661fc55)
When it happens
Trigger: Thrown at lib/streamlit/elements/dialog_decorator.py:56 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of streamlit/streamlit@202661fc55 (2026-08-26).
Data as JSON: /api/errors/55edda76747ec294.
Report an issue: GitHub.