deepset-ai/haystack · error

Unknown table format

Error message

Unknown table format '{string}'. Supported formats are: {list(enum_map.keys())}

What it means

DOCXTableFormat.from_str converts a user string into the DOCXTableFormat enum by exact (case-insensitive) value match. If the string is not one of the enum's values, it raises ValueError listing the valid options.

Solutions

  1. Use one of the listed supported values from the error message, e.g. from_str('csv').
  2. Trim whitespace and lowercase the string before calling (from_str lowercases already, but strip spaces).
  3. Update the config key to a valid enum value.
  4. Check the enum definition in haystack/components/converters/docx.py for exact accepted values.

Example fix

// before
fmt = DOCXTableFormat.from_str("markdown-table")
// after
fmt = DOCXTableFormat.from_str("markdown")
Defensive patterns

Strategy: validation

Validate before calling

VALID = {e.value for e in DOCXTableFormat}
fmt_input = fmt_input.strip().lower()
if fmt_input not in VALID:
    raise ValueError(f"{fmt_input!r} not in {sorted(VALID)}")

Type guard

def is_valid_table_format(s: str) -> bool:
    return s.strip().lower() in {e.value for e in DOCXTableFormat}

Try / catch

try:
    fmt = DOCXTableFormat.from_str(user_input)
except ValueError as e:
    logger.warning("%s; defaulting to %s", e, DOCXTableFormat.CSV)
    fmt = DOCXTableFormat.CSV

Prevention

When it happens

Trigger: Calling DOCXTableFormat.from_str('markdown-table') or passing table_format='csv ' with whitespace, or a synonym like 'grid' that is not an enum value, to a DOCX converter.

Common situations: Typo in pipeline YAML; using format names from another library (e.g. pandas to_markdown variants); copy-pasting with trailing spaces or quotes.

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 deepset-ai/haystack@e318778c9b (2026-08-30). Data as JSON: /api/errors/ec11aefafcc8f7ec. Report an issue: GitHub.

Appendix: source

Thrown at haystack/components/converters/docx.py:90

    Supported formats for storing DOCX tabular data in a Document.
    """

    MARKDOWN = "markdown"
    CSV = "csv"

    def __str__(self) -> str:
        return self.value

    @staticmethod
    def from_str(string: str) -> "DOCXTableFormat":
        """
        Convert a string to a DOCXTableFormat enum.
        """
        enum_map = {e.value: e for e in DOCXTableFormat}
        table_format = enum_map.get(string.lower())
        if table_format is None:
            msg = f"Unknown table format '{string}'. Supported formats are: {list(enum_map.keys())}"
            raise ValueError(msg)
        return table_format


DOCXLinkFormat = LinkFormat


@component
class DOCXToDocument:
    """
    Converts DOCX files to Documents.

    Uses `python-docx` library to convert the DOCX file to a document.
    This component does not preserve page breaks in the original document.

    Usage example:

    ```python
    from haystack.components.converters.docx import DOCXToDocument, DOCXTableFormat, DOCXLinkFormat

View on GitHub (pinned to e318778c9b)