datawhalechina/hello-agents · error · ValueError
Selected table_id '{requested_table_id}' was not found in th
Error message
Selected table_id '{requested_table_id}' was not found in the extracted candidate tables. What it means
After pdfplumber extracts candidate tables, if a selected_table_id was supplied, ingest_document looks it up among the extracted records; no match raises ValueError "Selected table_id '...' was not found in the extracted candidate tables." The id must be one of the table_ids reported by a prior preview/ingestion run for that exact PDF.
Source
Thrown at Co-creation-projects/healer-666-Academic-Data-Agent/src/data_analysis_agent/document_ingestion.py:351
raise ValueError("V1 暂不支持 vision_fallback,请先使用文本型 PDF 或手动裁剪目标表格。")
extracted_tables_dir = data_dir / "extracted_tables"
cleaned_data_path = (data_dir / "cleaned_data.csv").resolve()
parsed_document_path = (data_dir / "parsed_document.json").resolve()
full_text, records = _extract_pdf_payload(
source_path,
max_pdf_pages=max_pdf_pages,
max_candidate_tables=max_candidate_tables,
extracted_tables_dir=extracted_tables_dir,
)
background_literature_context = _extract_background_context(full_text)
requested_table_id = str(selected_table_id or "").strip()
requested_record = None
if requested_table_id:
requested_record = next((record for record in records if record.table_id == requested_table_id), None)
if requested_record is None:
raise ValueError(
f"Selected table_id '{requested_table_id}' was not found in the extracted candidate tables."
)
if not requested_record.numeric_columns:
raise ValueError(
f"Selected table_id '{requested_table_id}' does not contain any numeric columns and cannot be analyzed."
)
primary_record = requested_record or _select_primary_table(records)
warnings: list[str] = []
if primary_record is None:
summary = (
"PDF 解析失败:未提取到满足主表路由规则的结构化表格。"
"V1 暂不支持复杂多表路由或扫描件恢复,请手动裁剪 PDF 或改上传目标表格。"
)
parsed_payload = _serialize_parsed_document(
source_pdf=source_path,
background_literature_context=background_literature_context,
full_text_excerpt=full_text[:2000],View on GitHub (pinned to 606a07d341)
Solutions
- Re-run preview_pdf_tables (or check the candidate_table_summaries in the previous result) on the same file with the same page/table limits to get fresh table_ids.
- Pass the exact id string returned by that run, unmodified.
- If you don't need a specific table, omit selected_table_id so `_select_primary_table` picks one automatically.
- Keep ingestion parameters (max_pdf_pages, max_candidate_tables) identical between the preview that produced the id and the ingest that consumes it.
Defensive patterns
Strategy: validation
Validate before calling
def selected_id_exists(preview_result, table_id: str) -> bool:
ids = {c["table_id"] for c in preview_result.candidate_table_summaries}
return table_id in ids
# one flow: preview then ingest with the SAME parameters
preview = preview_pdf_tables(pdf_path, max_pdf_pages=P, max_candidate_tables=T)
if not selected_id_exists(preview, chosen_id):
raise ValueError(f"{chosen_id!r} not among {[c['table_id'] for c in preview.candidate_table_summaries]}") Try / catch
try:
result = ingest_document(pdf_path, data_dir, logs_dir, selected_table_id=tid,
max_pdf_pages=P, max_candidate_tables=T)
except ValueError as e:
if "not found in the extracted candidate tables" in str(e):
result = ingest_document(pdf_path, data_dir, logs_dir,
max_pdf_pages=P, max_candidate_tables=T) # auto-select primary table
else:
raise Prevention
- Always preview and select within the same parameter set (max_pdf_pages, max_candidate_tables).
- Treat table_ids as ephemeral per-extraction: re-preview whenever the PDF or parameters change.
- Store the preview result alongside the id you pass so you can refresh it in one step.
When it happens
Trigger: Passing a table_id from an earlier run against a different PDF, from a run with different max_pdf_pages/max_candidate_tables (which changes extraction and thus ids), a typo'd id, or an id whose table failed extraction this time.
Common situations: Multi-turn workflows where the user previews tables, edits parameters, then re-selects by stale id; PDFs regenerated upstream so table ordering/ids shift; ids copied with whitespace or case changes.
Related errors
- Unsupported input file format: {source_path.suffix}
- Unsupported latency_mode: {latency_mode}
- Unsupported vision_review_mode: {vision_review_mode}
- Unsupported quality_mode: {quality_mode}
- Unsupported data file format: {data_path.suffix}
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/f7f8506bf8abbde5.
Report an issue: GitHub.