{"record":{"id":"be3fb18f589fa927","repo":"PaddlePaddle/PaddleOCR","slug":"resource-filename-must-not-be-empty","errorCode":null,"errorMessage":"Resource filename must not be empty.","messagePattern":"Resource filename must not be empty\\.","errorType":"validation","errorClass":"InvalidRequestError","httpStatus":null,"severity":"error","filePath":"paddleocr/_api_client/_resources.py","lineNumber":209,"sourceCode":"    _validate_result_resource_filename(name)\n    return name\n\n\ndef _safe_resource_extension(resource_url: str) -> str:\n    parsed = urlparse(resource_url)\n    suffix = Path(unquote(parsed.path)).suffix\n    if not suffix:\n        return \"\"\n    try:\n        _validate_result_resource_filename(f\"resource{suffix}\")\n    except InvalidRequestError:\n        return \"\"\n    return suffix\n\n\ndef _validate_result_resource_filename(name: str) -> None:\n    if not name:\n        raise InvalidRequestError(\"Resource filename must not be empty.\")\n    path = Path(name)\n    if path.name != name or \"/\" in name or \"\\\\\" in name or name in (\".\", \"..\"):\n        raise InvalidRequestError(f\"Unsafe resource filename: {name}\")\n","sourceCodeStart":191,"sourceCodeEnd":213,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/_resources.py#L191-L213","documentation":"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 ''.","triggerScenarios":"Calling paddleocr._api_client._resources._validate_result_resource_filename('') directly, or new internal code passing an unvalidated empty filename for a result resource.","commonSituations":"Almost never seen by users; internal invariant check. Could surface after refactoring of the resources helper or via direct private-API use.","solutions":["Check the argument before calling the validator: skip handling when the filename is empty","If writing internal code, derive the filename from Path(url).name and handle the empty case upstream like _extract_suffix does (return '')"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from paddleocr._api_client._resources import _validate_result_resource_filename\n\ndef safe_validate(name: str) -> None:\n    if name:  # only validate non-empty names\n        _validate_result_resource_filename(name)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call the private validator with an empty string","Derive filenames from Path(url).name and short-circuit on empty"],"tags":["api-client","validation","internal"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}