PaddlePaddle/PaddleOCR · error · InvalidRequestError

Resource filename must not be empty.

Error message

Resource filename must not be empty.

What it means

Raised by _validate_result_resource_filename when the name passed to it is an empty string. The function guards result-resource filenames on the API client: an empty name is rejected before any filesystem or URL handling occurs. In the shown call path the caller always builds 'resource{suffix}', so reaching this error means the validator was invoked directly with ''.

Source

Thrown at paddleocr/_api_client/_resources.py:209

    _validate_result_resource_filename(name)
    return name


def _safe_resource_extension(resource_url: str) -> str:
    parsed = urlparse(resource_url)
    suffix = Path(unquote(parsed.path)).suffix
    if not suffix:
        return ""
    try:
        _validate_result_resource_filename(f"resource{suffix}")
    except InvalidRequestError:
        return ""
    return suffix


def _validate_result_resource_filename(name: str) -> None:
    if not name:
        raise InvalidRequestError("Resource filename must not be empty.")
    path = Path(name)
    if path.name != name or "/" in name or "\\" in name or name in (".", ".."):
        raise InvalidRequestError(f"Unsafe resource filename: {name}")

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Check the argument before calling the validator: skip handling when the filename is empty
  2. If writing internal code, derive the filename from Path(url).name and handle the empty case upstream like _extract_suffix does (return '')
Defensive patterns

Strategy: validation

Validate before calling

from paddleocr._api_client._resources import _validate_result_resource_filename

def safe_validate(name: str) -> None:
    if name:  # only validate non-empty names
        _validate_result_resource_filename(name)

Prevention

When it happens

Trigger: Calling paddleocr._api_client._resources._validate_result_resource_filename('') directly, or new internal code passing an unvalidated empty filename for a result resource.

Common situations: Almost never seen by users; internal invariant check. Could surface after refactoring of the resources helper or via direct private-API use.

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/be3fb18f589fa927. Report an issue: GitHub.