langchain-ai/langgraph · error · IsADirectoryError

Local module must be a file

Error message

Local module must be a file: {resolved}

What it means

The graph path resolved to an existing filesystem entry, but it is a directory rather than a file. The loader expects the path to point to the .py file containing the graph variable, so IsADirectoryError is raised.

Solutions

  1. Point the graph 'path' at the specific Python file, e.g. './myapp/agent.py:graph' instead of './myapp'.
  2. Add the module:attr suffix if it was omitted.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at libs/cli/langgraph_cli/config.py:897 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26). Data as JSON: /api/errors/374c66591e6f12d3. Report an issue: GitHub.

Appendix: source

Thrown at libs/cli/langgraph_cli/config.py:897

                f"Graph '{graph_id}' must be a string or a dictionary with a 'path' key."
            )

        module_str, _, attr_str = import_str.partition(":")
        if not module_str or not attr_str:
            message = (
                'Import string "{import_str}" must be in format "<module>:<attribute>".'
            )
            raise ValueError(message.format(import_str=import_str))

        # Check for either forward slash or backslash in the module string
        # to determine if it's a file path.
        if "/" in module_str or "\\" in module_str:
            # Resolve the local path properly on the current OS
            resolved = (config_path.parent / module_str).resolve()
            if not resolved.exists():
                raise FileNotFoundError(f"Could not find local module: {resolved}")
            elif not resolved.is_file():
                raise IsADirectoryError(f"Local module must be a file: {resolved}")
            else:
                for path in local_deps.real_pkgs:
                    if resolved.is_relative_to(path):
                        container_path = (
                            pathlib.Path("/deps")
                            / path.name
                            / resolved.relative_to(path)
                        )
                        module_str = container_path.as_posix()
                        break
                else:
                    for faux_pkg, (_, destpath) in local_deps.faux_pkgs.items():
                        if resolved.is_relative_to(faux_pkg):
                            container_subpath = resolved.relative_to(faux_pkg)
                            # Construct the final path, ensuring POSIX style
                            module_str = f"{destpath}/{container_subpath.as_posix()}"
                            break
                    else:

View on GitHub (pinned to 38031739e5)