{"record":{"id":"55edda76747ec294","repo":"streamlit/streamlit","slug":"dialogs-may-not-be-nested-inside-other-dialogs","errorCode":null,"errorMessage":"Dialogs may not be nested inside other dialogs.","messagePattern":"Dialogs may not be nested inside other dialogs\\.","errorType":"validation","errorClass":"StreamlitAPIException","httpStatus":null,"severity":"error","filePath":"lib/streamlit/elements/dialog_decorator.py","lineNumber":56,"sourceCode":"    as this populates the dg_stack in delta_generator correctly.\n\n    This does not detect the edge case in which someone calls, for example,\n    `with st.sidebar` inside of a dialog function and opens a dialog in there, as\n    `with st.sidebar` pushes the new DeltaGenerator to the stack. In order to check for\n    that edge case, we could try to check all DeltaGenerators in the stack, and not only\n    the last one. Since we deem this to be an edge case, we lean towards simplicity\n    here.\n\n    Raises\n    ------\n    StreamlitAPIException\n        Raised if the user tries to nest dialogs inside of each other.\n    \"\"\"\n    last_dg_in_current_context = get_last_dg_added_to_context_stack()\n    if last_dg_in_current_context and \"dialog\" in set(\n        last_dg_in_current_context._ancestor_block_types\n    ):\n        raise StreamlitAPIException(\"Dialogs may not be nested inside other dialogs.\")\n\n\nF = TypeVar(\"F\", bound=Callable[..., Any])\n\n\ndef _dialog_decorator(\n    non_optional_func: F,\n    title: str,\n    *,\n    width: DialogWidth = \"small\",\n    dismissible: bool = True,\n    icon: str | None = None,\n    on_dismiss: Literal[\"ignore\", \"rerun\"] | WidgetCallback = \"ignore\",\n) -> F:\n    if title is None or title == \"\":\n        raise StreamlitAPIException(\n            \"A non-empty `title` argument has to be provided for dialogs, for example \"\n            '`@st.dialog(\"Example Title\")`.'","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/streamlit/streamlit/blob/202661fc552db98c2ba0bb0e113d619689baf9de/lib/streamlit/elements/dialog_decorator.py#L38-L74","documentation":"Error \"Dialogs may not be nested inside other dialogs.\" thrown in streamlit/streamlit.","triggerScenarios":"Thrown at lib/streamlit/elements/dialog_decorator.py:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"202661fc552db98c2ba0bb0e113d619689baf9de","analyzedAt":"2026-08-26T09:13:21.291Z","schemaVersion":2},"datasetVersion":"2026-08-26T14:46:13.012Z"}