{"record":{"id":"766851c7d7c1dcc6","repo":"PaddlePaddle/PaddleOCR","slug":"parent","errorCode":null,"errorMessage":"{parent}","messagePattern":"\\{parent\\}","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"paddleocr/_api_client/_resources.py","lineNumber":136,"sourceCode":"            )\n    return saved_paths\n\n\ndef _resolve_destination(\n    url_path: str, destination: str, filename: Optional[str]\n) -> Path:\n    destination_path = Path(destination)\n    if filename is not None:\n        _validate_result_resource_filename(filename)\n        target = destination_path / filename\n    elif destination_path.exists() and destination_path.is_dir():\n        target = destination_path / _safe_url_basename(url_path)\n    else:\n        target = destination_path\n\n    parent = target.parent\n    if not parent.exists():\n        raise FileNotFoundError(str(parent))\n    if not parent.is_dir():\n        raise InvalidRequestError(f\"Destination parent must be a directory: {parent}\")\n    return target\n\n\ndef _require_existing_directory(destination: str) -> Path:\n    dest_dir = Path(destination)\n    if not dest_dir.exists():\n        raise FileNotFoundError(destination)\n    if not dest_dir.is_dir():\n        raise InvalidRequestError(\n            f\"Destination must be an existing directory: {destination}\"\n        )\n    return dest_dir\n\n\ndef _require_writable_target(target: Path, overwrite: bool) -> None:\n    if target.exists() and not overwrite:","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/_resources.py#L118-L154","documentation":"Python builtin FileNotFoundError raised by _resolve_destination when the parent directory of the computed target path does not exist. Target = destination/filename, or destination/url-basename when destination is an existing directory, or destination itself otherwise; the check then requires target.parent to exist.","triggerScenarios":"save_resource(url, '/missing/dir/out.png') — the /missing/dir does not exist; or destination is a not-yet-created path (e.g. an output directory the caller never created) and its parent is absent; or filename contains a directory component ('sub/img.png') whose subdirectory does not exist under destination.","commonSituations":"Assuming save_resource creates output directories (it does not — mkdir is the caller's job); output dir path with a typo; filename passed with an uncreated subfolder; containerized runs where the mounted output path differs from what the code assumes.","solutions":["Create the directory first: Path(destination).parent.mkdir(parents=True, exist_ok=True) (or the output dir itself when saving multiple files)","Verify the destination path spelling and that mounts exist in the current environment","If filename may contain subpaths, create target.parent, not just the destination dir"],"exampleFix":"# before\nsave_resource(url, '/out/pages/page-1.png')  # /out/pages missing\n\n# after\nfrom pathlib import Path\nPath('/out/pages').mkdir(parents=True, exist_ok=True)\nsave_resource(url, '/out/pages/page-1.png')","handlingStrategy":"validation","validationCode":"from pathlib import Path\nPath(destination).expanduser().parent.mkdir(parents=True, exist_ok=True)\nassert Path(destination).parent.is_dir()","typeGuard":null,"tryCatchPattern":"try:\n    save_resource(url, dest)\nexcept FileNotFoundError as e:\n    Path(str(e)).mkdir(parents=True, exist_ok=True)  # message is the missing dir\n    save_resource(url, dest)","preventionTips":["Create output directories at pipeline start (mkdir parents=True), not per file","Validate output roots against actual mounts in containers before running"],"tags":["filesystem","path","download"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}