{"record":{"id":"998d83abd34b26d0","repo":"OpenBB-finance/OpenBB","slug":"error-the-app-file-app-path-does-not-exist","errorCode":null,"errorMessage":"Error: The app file '{app_path}' does not exist","messagePattern":"Error: The app file '(.+?)' does not exist","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/mcp_server/openbb_mcp_server/utils/app_import.py","lineNumber":69,"sourceCode":"                file_path = str(cwd.joinpath(module_path).resolve())\n            else:\n                file_path = module_path\n\n            if not Path(file_path).exists():\n                raise FileNotFoundError(  # pylint: disable=raise-missing-from\n                    f\"Error: Neither module '{module_path}' could be imported nor file '{file_path}' exists\"\n                )\n\n            module = _load_module_from_file_path(file_path)\n\n    # Case 2: File path (e.g., \"main.py\" or \"my_app/main.py\")\n    else:\n        if not Path(app_path).is_absolute():\n            cwd = Path.cwd()\n            app_path = str(cwd.joinpath(app_path).resolve())\n\n        if not Path(app_path).exists():\n            raise FileNotFoundError(f\"Error: The app file '{app_path}' does not exist\")\n\n        module = _load_module_from_file_path(app_path)\n\n    if not hasattr(module, name):\n        raise AttributeError(\n            f\"Error: The app file '{app_path}' does not contain an '{name}' instance\"\n        )\n\n    app_or_factory = getattr(module, name)\n\n    # Here we use the same approach as uvicorn to handle factory functions.\n    # This prevents us from relying on explicit type annotations.\n    # See: https://github.com/encode/uvicorn/blob/master/uvicorn/config.py\n    try:\n        app = app_or_factory()\n        if not factory:\n            print(  # noqa: T201\n                \"\\n\\n[WARNING]   \"","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/mcp_server/openbb_mcp_server/utils/app_import.py#L51-L87","documentation":"FileNotFoundError raised when the --app argument looks like a plain file path (no colon notation) and that file does not exist after resolving relative paths against the current working directory. This is the file-path branch of the app importer, as opposed to the module branch of error 128.","triggerScenarios":"--app ./some_app.py when some_app.py is not in the CWD; the path is resolved with Path.cwd().joinpath(...).resolve() first, so any relative path is interpreted relative to where the command was launched, not the config file or package root.","commonSituations":"Launching the server via a service manager (systemd, Docker) whose working directory differs from the developer's shell, typos in the filename, moving/renaming the app file without updating the command, trailing spaces in the path.","solutions":["Use an absolute path: --app /opt/myapp/main.py","Or cd into the directory containing the file before launching","Verify with ls or Path('--app value').exists() that the resolved path is real"],"exampleFix":"# before\nopenbb-mcp --app ./some_app.py   # launched from a different cwd\n\n# after\nopenbb-mcp --app /abs/path/to/some_app.py","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\np = Path(app_path)\nresolved = p if p.is_absolute() else (Path.cwd() / p).resolve()\nif not resolved.exists():\n    raise ValueError(f\"app file not found at resolved path: {resolved}\")","typeGuard":"def app_file_exists(app_path: str) -> bool:\n    p = Path(app_path)\n    resolved = p if p.is_absolute() else (Path.cwd() / p).resolve()\n    return resolved.is_file()","tryCatchPattern":"try:\n    app = import_app(app_path, \"app\")\nexcept FileNotFoundError as e:\n    if \"does not exist\" in str(e):\n        app = import_app(str(PROJECT_ROOT / \"main.py\"), \"app\")  # known-good absolute path\n    else:\n        raise","preventionTips":["Use absolute paths in service definitions (systemd/Docker) where cwd is unpredictable","Set WorkingDirectory= (systemd) or WORKDIR (Docker) explicitly","Strip whitespace from templated paths in launch scripts"],"tags":["python","cli","file-not-found","path-resolution","fastapi"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}