{"record":{"id":"bc640494d86dd751","repo":"FoundationAgents/MetaGPT","slug":"not-allowed-file-ext-file-extension-must-be-one","errorCode":null,"errorMessage":"Not allowed {file_ext} File extension must be one of {allowed_file_extensions}","messagePattern":"Not allowed (.+?) File extension must be one of (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/utils/omniparse_client.py","lineNumber":194,"sourceCode":"\n        Raises:\n            ValueError: If the file extension is not allowed.\n\n        Returns:\n        \"\"\"\n        verify_file_path = None\n        if isinstance(file_input, (str, Path)):\n            verify_file_path = str(file_input)\n        elif isinstance(file_input, bytes) and bytes_filename:\n            verify_file_path = bytes_filename\n\n        if not verify_file_path:\n            # Do not verify if only byte data is provided\n            return\n\n        file_ext = Path(verify_file_path).suffix.lower()\n        if file_ext not in allowed_file_extensions:\n            raise ValueError(f\"Not allowed {file_ext} File extension must be one of {allowed_file_extensions}\")\n\n    @staticmethod\n    async def get_file_info(\n        file_input: Union[str, bytes, Path],\n        bytes_filename: str = None,\n        only_bytes: bool = False,\n    ) -> Union[bytes, tuple]:\n        \"\"\"\n        Get file information.\n\n        Args:\n            file_input: File path or file byte data.\n            bytes_filename: Filename to use when uploading byte data, useful for determining MIME type.\n            only_bytes: Whether to return only byte data. Default is False, which returns a tuple.\n\n        Raises:\n            ValueError: If bytes_filename is not provided when file_input is bytes or if file_input is not a valid type.\n","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/utils/omniparse_client.py#L176-L212","documentation":"Raised by OmniParseClient's file extension check: before uploading, it derives a path (the input path, or bytes_filename for raw bytes) and requires its lowercase suffix to be in the server's allowed_file_extensions list; otherwise it refuses the upload with ValueError.","triggerScenarios":"Calling the client's parse/file endpoint with a file whose extension is not in allowed_file_extensions (e.g. .exe, .csv when only document types are allowed), or passing bytes with a bytes_filename like 'data.bin' whose extension is not allowed.","commonSituations":"Pointing the client at a file type the deployed OmniParse server build does not support; mismatched allowed list between client config and server capabilities; misnamed files with wrong suffix.","solutions":["Convert the file to an allowed format first (e.g. re-save as .pdf/.md/.docx depending on the allowed list).","Check client.allowed_file_extensions (or the server's /parse' docs) before uploading and skip unsupported types.","If the server actually supports the type, update the allowed_file_extensions used by the client so the guard matches the server."],"exampleFix":"# before\nawait client.parsing('report.exe')  # ValueError: Not allowed .exe ...\n\n# after\next = Path('report.exe').suffix.lower()\nassert ext in client.allowed_file_extensions, f'{ext} unsupported'\nawait client.parsing('report.pdf')","handlingStrategy":"validation","validationCode":"from pathlib import Path\ndef ext_allowed(path_or_name: str, allowed: set[str]) -> bool:\n    return Path(path_or_name).suffix.lower() in allowed\n\n# usage: assert ext_allowed('doc.pdf', client.allowed_file_extensions)","typeGuard":null,"tryCatchPattern":"try:\n    res = await client.parsing(path)\nexcept ValueError as e:\n    if 'Not allowed' in str(e):\n        logger.warning('Convert %s to an allowed format first', path)","preventionTips":["Read client.allowed_file_extensions before queuing files.","Filter/convert unsupported files upstream (e.g. .doc -> .pdf).","Keep bytes_filename's extension consistent with the actual content."],"tags":["omniparse","file-upload","validation"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}