{"record":{"id":"1fc4dcfcd06ab037","repo":"xtekky/gpt4free","slug":"pa-provider-file-not-found-file-path","errorCode":null,"errorMessage":"PA provider file not found: {file_path}","messagePattern":"PA provider file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"g4f/mcp/pa_provider.py","lineNumber":746,"sourceCode":"    The file is executed inside the safe sandbox.  The module is expected to\n    define a class named ``Provider``; if that name is absent the first class\n    with a ``create_completion`` or ``create_async_generator`` attribute is\n    returned instead.\n\n    Args:\n        file_path: Path to the ``.pa.py`` file.\n\n    Returns:\n        The provider class, or ``None`` if none could be found.\n\n    Raises:\n        FileNotFoundError: If *file_path* does not exist.\n        ValueError: If *file_path* does not end with ``.pa.py``.\n        RuntimeError: If the file fails to execute.\n    \"\"\"\n    file_path = Path(file_path)\n    if not file_path.exists():\n        raise FileNotFoundError(f\"PA provider file not found: {file_path}\")\n    if not file_path.name.endswith(\".pa.py\"):\n        raise ValueError(f\"File must have .pa.py extension: {file_path}\")\n\n    code = file_path.read_text(encoding=\"utf-8\")\n    result = execute_safe_code(code, file_path=file_path, timeout=0.1, max_depth=100)\n\n    if not result.success:\n        raise RuntimeError(\n            f\"Failed to load PA provider from {file_path}:\\n{result.error}\"\n        )\n\n    # Prefer an explicit 'Provider' name\n    provider_class = result.locals.get(\"Provider\")\n    if provider_class is not None:\n        return provider_class\n\n    # Fall back to any class that looks like a provider\n    for obj in result.locals.values():","sourceCodeStart":728,"sourceCodeEnd":764,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/mcp/pa_provider.py#L728-L764","documentation":"Raised by load_pa_provider when the given path does not exist (Path.exists() is false). This is the entry point that loads a sandboxed PA provider file, so it is the first sanity check before extension and execution checks. The message embeds the exact path for quick diagnosis.","triggerScenarios":"Calling load_pa_provider with a typo'd path, a relative path resolved against the wrong working directory, or a file that was moved/deleted after registration.","commonSituations":"MCP tool invocations referencing a stale workspace path; scripts run from a different cwd so a relative path no longer resolves; provider files renamed from .py to .pa.py leaving old references.","solutions":["Verify the path exists before calling: Path(p).is_file()","Use absolute paths built from the workspace directory rather than cwd-relative paths","Re-register/re-point the provider after moving or renaming the file"],"exampleFix":"# before\nload_pa_provider('myprov.pa.py')  # relative, wrong cwd\n\n# after\nload_pa_provider(get_workspace_dir() / 'myprov.pa.py')","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(file_path)\nassert p.is_file(), f\"missing PA provider file: {p}\"","typeGuard":null,"tryCatchPattern":"try:\n    provider_cls = load_pa_provider(path)\nexcept FileNotFoundError:\n    provider_cls = None  # log and skip / re-register with correct path","preventionTips":["Build provider paths from the workspace root, never from cwd","Validate is_file() before loading, especially for user-registered paths","Re-check registered provider paths after workspace moves"],"tags":["filesystem","pa-provider","path","validation"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}