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
WordParser.__init__ validates its table_format argument and only accepts 'markdown' or 'json'; any other string raises ValueError at construction time.
Source
Thrown at src/agentscope/rag/_parser/_word.py:228
:class:`DataBlock` sections. Set to ``False`` to keep
a text-only index.
separate_table (`bool`, defaults to ``False``):
When ``True``, each table becomes its own text section,
never merged with surrounding paragraphs.
table_format (`Literal["markdown", "json"]`, defaults to
``"markdown"``):
How to render tables. ``"markdown"`` uses pipe-table
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.
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
async def parse(
self,
file: bytes | str,
filename: str,
) -> list[Section]:
"""Parse a DOCX file into a list of :class:`Section` objects.
Args:
file (`bytes | str`):
Either the raw DOCX bytes, or a filesystem path to the
DOCX file.View on GitHub (pinned to e90f1c7592)
Solutions
- Use exactly 'markdown' or 'json'
- Check spelling/case if building from config
- Validate config values before parser construction
Example fix
# before wp = WordParser(table_format='md') # after wp = WordParser(table_format='markdown')
Defensive patterns
Strategy: validation
Validate before calling
assert table_format in ('markdown', 'json') Type guard
def is_valid_table_format(v: str) -> bool:
return v in ('markdown', 'json') Prevention
- Validate config values against the documented enum before constructing parsers
- Use constants instead of free-form strings
When it happens
Trigger: WordParser(table_format='csv') or 'html', 'md', 'JSON' (case-sensitive), or passing a table_format intended for another parser.
Common situations: Copy-pasting config from a different library, typos, or assuming case-insensitivity; often caught when constructing parsers programmatically from a config dict.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- The injection template must contain the '{runtime_state}' pl
- MCP {card.name!r} produced an invalid client: {e}
- DimensionPolicy: kind=ANY requires dimension=None, got dimen
- DimensionPolicy: kind={self.kind.value} requires a positive
- "AgentScopeLLM requires `model` in the config to be an Agent
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/3380d0d1565c64d9.
Report an issue: GitHub.