datawhalechina/hello-agents · error · ValueError
Unsupported input file format: {source_path.suffix}
Error message
Unsupported input file format: {source_path.suffix} What it means
`preview_pdf_tables` resolves the input path and immediately rejects it with ValueError unless its lowercased suffix is in SUPPORTED_DOCUMENT_SUFFIXES (the PDF-style document set). Message: 'Unsupported input file format: {suffix}'. This guards the table-preview entrypoint before any pdfplumber work starts.
Source
Thrown at Co-creation-projects/healer-666-Academic-Data-Agent/src/data_analysis_agent/document_ingestion.py:252
"pdf_multi_table_mode": True,
"source_pdf": source_pdf.resolve().as_posix(),
"background_literature_context": background_literature_context,
"text_excerpt": full_text_excerpt,
"selected_table_id": selected_table_id,
"candidate_tables": candidate_tables,
"candidate_table_summaries": candidate_tables,
}
def preview_pdf_tables(
data_path: str | Path,
*,
max_pdf_pages: int = 20,
max_candidate_tables: int = 5,
) -> PdfPreviewResult:
source_path = Path(data_path).resolve()
if source_path.suffix.lower() not in SUPPORTED_DOCUMENT_SUFFIXES:
raise ValueError(f"Unsupported input file format: {source_path.suffix}")
scratch_root = source_path.parent / ".pdf_preview_tmp"
scratch_root.mkdir(parents=True, exist_ok=True)
scratch_dir = Path(tempfile.mkdtemp(prefix="pdf_preview_", dir=scratch_root))
try:
full_text, records = _extract_pdf_payload(
source_path,
max_pdf_pages=max_pdf_pages,
max_candidate_tables=max_candidate_tables,
extracted_tables_dir=scratch_dir,
persist_csv=False,
)
finally:
shutil.rmtree(scratch_dir, ignore_errors=True)
default_record = _select_primary_table(records)
warnings: list[str] = []
if records:View on GitHub (pinned to 606a07d341)
Solutions
- Pass a file whose extension is in SUPPORTED_DOCUMENT_SUFFIXES (check that constant; typically .pdf).
- For .csv/.xlsx inputs, skip document preview — they are already structured tables.
- Convert .docx to PDF (e.g. via LibreOffice) before previewing tables.
- Ensure the path points at the original source document, not a generated artifact.
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
def is_supported_document(path: str | Path, supported: set[str]) -> bool:
return Path(path).suffix.lower() in supported
# before calling preview_pdf_tables
if not is_supported_document(pdf_path, SUPPORTED_DOCUMENT_SUFFIXES):
raise ValueError(f"preview needs a document file, got {Path(pdf_path).suffix}") Try / catch
try:
preview = preview_pdf_tables(path)
except ValueError as e:
if "Unsupported input file format" in str(e):
path = convert_to_pdf(path) # e.g. LibreOffice export
preview = preview_pdf_tables(path)
else:
raise Prevention
- Route by type: tabular files (.csv/.xlsx) skip document preview entirely.
- Convert office formats to PDF before table preview.
- Import SUPPORTED_DOCUMENT_SUFFIXES from the package rather than hardcoding the set.
When it happens
Trigger: Calling preview_pdf_tables on a .csv/.xlsx (tabular, not a document — use the tabular path instead), on .docx/.png/.jpg, or on a scanned PDF stored with an odd extension; also fires for files with no extension.
Common situations: Users trying to preview tables inside Word documents or images; passing the wrong path variable (a cleaned CSV output instead of the source PDF); double extensions like .pdf.bak.
Related errors
- Unsupported data file format: {data_path.suffix}
- Selected table_id '{requested_table_id}' was not found in th
- Unsupported latency_mode: {latency_mode}
- Unsupported vision_review_mode: {vision_review_mode}
- Unsupported quality_mode: {quality_mode}
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/c585d48607a88ade.
Report an issue: GitHub.