agentscope-ai/agentscope · error · ValueError

The table_format must be one of 'markdown' or 'json', got {t

Error message

The table_format must be one of 'markdown' or 'json', got {table_format!r}.

What it means

PPTParser only accepts table_format of 'markdown' or 'json'; any other value is rejected in __init__ with a ValueError echoing the invalid value.

Source

Thrown at src/agentscope/rag/_parser/_ppt.py:158

                syntax, escaping pipes and rendering cell line breaks
                as ``<br>``; ``"json"`` emits a JSON array prefixed with
                a ``<system-info>`` marker and preserves extracted cell
                strings without Markdown rendering.
            slide_prefix (`str | None`, defaults to
                ``"<slide index={index}>"``):
                Prepended to the first text section of each slide.
                Supports the ``{index}`` placeholder (starting at 1).  Use
                ``None`` to disable.
            slide_suffix (`str | None`, defaults to ``"</slide>"``):
                Appended to the last text section of each slide.  Use
                ``None`` to disable.

        Raises:
            `ValueError`: If ``table_format`` is not one of
                ``"markdown"`` / ``"json"``.
        """
        if table_format not in ("markdown", "json"):
            raise ValueError(
                "The table_format must be one of 'markdown' or 'json', "
                f"got {table_format!r}.",
            )
        self.include_image = include_image
        self.separate_table = separate_table
        self.table_format = table_format
        self.slide_prefix = slide_prefix
        self.slide_suffix = slide_suffix

    async def parse(
        self,
        file: bytes | str,
        filename: str,
    ) -> list[Section]:
        """Parse a PPTX file into a list of :class:`Section` objects.

        Args:
            file (`bytes | str`):

View on GitHub (pinned to e90f1c7592)

Solutions

  1. Use exactly 'markdown' or 'json' (lowercase)
  2. Normalize user/config input to the allowed set before construction

Example fix

# before
parser = PPTParser(table_format='md')

# after
parser = PPTParser(table_format='markdown')
Defensive patterns

Strategy: validation

Validate before calling

assert table_format in ('markdown', 'json'), f"bad table_format: {table_format}"

Type guard

def is_table_format(v: str) -> bool:
    return v in ('markdown', 'json')

Prevention

When it happens

Trigger: Constructing PPTParser(table_format='csv') or 'md'/'Markdown' (case-sensitive) or 'html'.

Common situations: Abbreviations like 'md'; case mismatch from configs; sharing format constants across parsers with different allowed values.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28). Data as JSON: /api/errors/9caff9fd5a7352da. Report an issue: GitHub.