{"record":{"id":"79c8524273c4940f","repo":"pola-rs/polars","slug":"invalid-plan-stage-plan-stage","errorCode":null,"errorMessage":"invalid plan stage '{plan_stage}'","messagePattern":"invalid plan stage '(.+?)'","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/frame.py","lineNumber":1527,"sourceCode":"        ...     \"a\"\n        ... ).show_graph()  # doctest: +SKIP\n        \"\"\"\n        engine_ = _select_engine(engine)\n\n        optimizations = optimizations.__copy__()\n        optimizations._pyoptflags.streaming = engine_.plan_engine == \"streaming\"\n        _ldf = self._ldf.with_optimizations(optimizations._pyoptflags)\n\n        if plan_stage == \"ir\":\n            dot = _ldf.to_dot(optimized)\n        elif plan_stage == \"physical\":\n            if engine_.plan_engine == \"streaming\" or engine_.plan_engine == \"auto\":\n                dot = _ldf.to_dot_streaming_phys(optimized)\n            else:\n                dot = _ldf.to_dot(optimized)\n        else:\n            error_msg = f\"invalid plan stage '{plan_stage}'\"\n            raise TypeError(error_msg)\n\n        return display_dot_graph(\n            dot=dot,\n            show=show,\n            output_path=output_path,\n            raw_output=raw_output,\n            figsize=figsize,\n        )\n\n    def inspect(self, fmt: str = \"{}\") -> LazyFrame:\n        \"\"\"\n        Inspect a node in the computation graph.\n\n        Print the value that this node in the computation graph evaluates to and pass on\n        the value.\n\n        .. engine-support:: in-memory\n","sourceCodeStart":1509,"sourceCodeEnd":1545,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/lazyframe/frame.py#L1509-L1545","documentation":"Sentinel for an unrecognized `plan_stage` argument in LazyFrame.show_graph. After engine selection and optimization-flag setup, the code branches on the known stages ('ir', 'physical', plus streaming/physical engine variants); a value outside that set falls through every branch, so the plan-visualization request is rejected as invalid.","triggerScenarios":"`lf.show_graph(plan_stage='optimized')`, `plan_stage='logical'`, typos like 'phys', or variables carrying stale stage names from older polars versions.","commonSituations":"Snippets from old tutorials (stage names changed across polars versions); typos; generic plan-visualization code parameterized with invalid values.","solutions":["Use plan_stage='ir' (optimized logical plan) or 'physical' (streaming physical plan)","Omit plan_stage for the default","Map legacy names: 'optimized' -> 'ir'"],"exampleFix":"// before\nlf.show_graph(plan_stage='optimized')\n\n// after\nlf.show_graph(plan_stage='ir')","handlingStrategy":"validation","validationCode":"VALID_STAGES = {'ir', 'physical'}\nassert plan_stage in VALID_STAGES, f\"plan_stage must be one of {VALID_STAGES}\"","typeGuard":"def is_valid_plan_stage(stage) -> bool:\n    return stage in ('ir', 'physical')","tryCatchPattern":"try:\n    lf.show_graph(plan_stage=stage)\nexcept TypeError as e:\n    if \"invalid plan stage\" in str(e):\n        lf.show_graph(plan_stage='ir')\n    else:\n        raise","preventionTips":["Only pass 'ir' or 'physical' for plan_stage","Check current polars docs — plan stage names changed across versions","Validate user-supplied stage strings against the allowed set"],"tags":["python","polars","visualization","argument-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}