Repository: streamlit/streamlit
File: lib/streamlit/elements/layouts.py (Python)

Code before:
            )

        if default and default not in tabs:
            raise StreamlitAPIException(
                f"The default tab '{default}' is not in the list of tabs."
            )

        if any(not isinstance(tab, str) for tab in tabs):
            raise StreamlitAPIException(
                "The tabs input list to st.tabs is only allowed to contain strings."
            )

        if (
            on_change is not None
            and not callable(on_change)
            and on_change not in {"ignore", "rerun"}
        ):
            raise StreamlitValueError(
                "on_change",
                ["'rerun'", "'ignore'", "None", "a callback function"],
            )

        if not callable(on_change) and (args is not None or kwargs is not None):
            raise StreamlitAPIException(
                "`args` and `kwargs` can only be used when `on_change` is a callable."
            )

        key = to_key(key)
        default_index = tabs.index(default) if default else 0
        is_stateful = on_change is not None and on_change != "ignore"

        element_id: str | None = None
        current_tab_label = tabs[default_index]

        if is_stateful:
            check_widget_policies(
                self.dg,
                key,
                on_change=on_change if callable(on_change) else None,
                default_value=None,
                writes_allowed=True,
                enable_check_callback_rules=callable(on_change),
            )

            ctx = get_script_run_ctx()

            element_id = compute_and_register_element_id(
                "tabs",
                user_key=key,
                key_as_main_identity=False,
                dg=self.dg,

Review comment (suggestion):
**suggestion:** I think it's slightly better here to just not throw the error because 1) for consistency, since I believe we are not doing it anywhere else, 2) with agents, it might be better to be a bit more forgiving.

Code after:
            )

        if default and default not in tabs:
            raise StreamlitAPIException(
                f"The default tab '{default}' is not in the list of tabs."
            )

        if any(not isinstance(tab, str) for tab in tabs):
            raise StreamlitAPIException(
                "The tabs input list to st.tabs is only allowed to contain strings."
            )

        if (
            on_change is not None
            and not callable(on_change)
            and on_change not in {"ignore", "rerun"}
        ):
            raise StreamlitValueError(
                "on_change",
                ["'rerun'", "'ignore'", "None", "a callback function"],
            )

        key = to_key(key)
        default_index = tabs.index(default) if default else 0
        is_stateful = on_change is not None and on_change != "ignore"

        element_id: str | None = None
        current_tab_label = tabs[default_index]

        if is_stateful:
            check_widget_policies(
                self.dg,
                key,
                on_change=on_change if callable(on_change) else None,
                default_value=None,
                writes_allowed=True,
                enable_check_callback_rules=callable(on_change),
            )

            ctx = get_script_run_ctx()

            element_id = compute_and_register_element_id(
                "tabs",
                user_key=key,
                key_as_main_identity=False,
                dg=self.dg,
                tabs=tuple(tabs),
                width=width,
                default=default,
            )