FoundationAgents/MetaGPT · error · ValueError

Not allowed {file_ext} File extension must be one of {allowe

Error message

Not allowed {file_ext} File extension must be one of {allowed_file_extensions}

What it means

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.

Source

Thrown at metagpt/utils/omniparse_client.py:194

        Raises:
            ValueError: If the file extension is not allowed.

        Returns:
        """
        verify_file_path = None
        if isinstance(file_input, (str, Path)):
            verify_file_path = str(file_input)
        elif isinstance(file_input, bytes) and bytes_filename:
            verify_file_path = bytes_filename

        if not verify_file_path:
            # Do not verify if only byte data is provided
            return

        file_ext = Path(verify_file_path).suffix.lower()
        if file_ext not in allowed_file_extensions:
            raise ValueError(f"Not allowed {file_ext} File extension must be one of {allowed_file_extensions}")

    @staticmethod
    async def get_file_info(
        file_input: Union[str, bytes, Path],
        bytes_filename: str = None,
        only_bytes: bool = False,
    ) -> Union[bytes, tuple]:
        """
        Get file information.

        Args:
            file_input: File path or file byte data.
            bytes_filename: Filename to use when uploading byte data, useful for determining MIME type.
            only_bytes: Whether to return only byte data. Default is False, which returns a tuple.

        Raises:
            ValueError: If bytes_filename is not provided when file_input is bytes or if file_input is not a valid type.

View on GitHub (pinned to 11cdf466d0)

Solutions

  1. Convert the file to an allowed format first (e.g. re-save as .pdf/.md/.docx depending on the allowed list).
  2. Check client.allowed_file_extensions (or the server's /parse' docs) before uploading and skip unsupported types.
  3. If the server actually supports the type, update the allowed_file_extensions used by the client so the guard matches the server.

Example fix

# before
await client.parsing('report.exe')  # ValueError: Not allowed .exe ...

# after
ext = Path('report.exe').suffix.lower()
assert ext in client.allowed_file_extensions, f'{ext} unsupported'
await client.parsing('report.pdf')
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
def ext_allowed(path_or_name: str, allowed: set[str]) -> bool:
    return Path(path_or_name).suffix.lower() in allowed

# usage: assert ext_allowed('doc.pdf', client.allowed_file_extensions)

Try / catch

try:
    res = await client.parsing(path)
except ValueError as e:
    if 'Not allowed' in str(e):
        logger.warning('Convert %s to an allowed format first', path)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14). Data as JSON: /api/errors/bc640494d86dd751. Report an issue: GitHub.