{"record":{"id":"f7f8506bf8abbde5","repo":"datawhalechina/hello-agents","slug":"selected-table-id-requested-table-id-was-not-f","errorCode":null,"errorMessage":"Selected table_id '{requested_table_id}' was not found in the extracted candidate tables.","messagePattern":"Selected table_id '(.+?)' was not found in the extracted candidate tables\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Co-creation-projects/healer-666-Academic-Data-Agent/src/data_analysis_agent/document_ingestion.py","lineNumber":351,"sourceCode":"        raise ValueError(\"V1 暂不支持 vision_fallback，请先使用文本型 PDF 或手动裁剪目标表格。\")\n\n    extracted_tables_dir = data_dir / \"extracted_tables\"\n    cleaned_data_path = (data_dir / \"cleaned_data.csv\").resolve()\n    parsed_document_path = (data_dir / \"parsed_document.json\").resolve()\n\n    full_text, records = _extract_pdf_payload(\n        source_path,\n        max_pdf_pages=max_pdf_pages,\n        max_candidate_tables=max_candidate_tables,\n        extracted_tables_dir=extracted_tables_dir,\n    )\n    background_literature_context = _extract_background_context(full_text)\n    requested_table_id = str(selected_table_id or \"\").strip()\n    requested_record = None\n    if requested_table_id:\n        requested_record = next((record for record in records if record.table_id == requested_table_id), None)\n        if requested_record is None:\n            raise ValueError(\n                f\"Selected table_id '{requested_table_id}' was not found in the extracted candidate tables.\"\n            )\n        if not requested_record.numeric_columns:\n            raise ValueError(\n                f\"Selected table_id '{requested_table_id}' does not contain any numeric columns and cannot be analyzed.\"\n            )\n    primary_record = requested_record or _select_primary_table(records)\n    warnings: list[str] = []\n\n    if primary_record is None:\n        summary = (\n            \"PDF 解析失败：未提取到满足主表路由规则的结构化表格。\"\n            \"V1 暂不支持复杂多表路由或扫描件恢复，请手动裁剪 PDF 或改上传目标表格。\"\n        )\n        parsed_payload = _serialize_parsed_document(\n            source_pdf=source_path,\n            background_literature_context=background_literature_context,\n            full_text_excerpt=full_text[:2000],","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/healer-666-Academic-Data-Agent/src/data_analysis_agent/document_ingestion.py#L333-L369","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def selected_id_exists(preview_result, table_id: str) -> bool:\n    ids = {c[\"table_id\"] for c in preview_result.candidate_table_summaries}\n    return table_id in ids\n\n# one flow: preview then ingest with the SAME parameters\npreview = preview_pdf_tables(pdf_path, max_pdf_pages=P, max_candidate_tables=T)\nif not selected_id_exists(preview, chosen_id):\n    raise ValueError(f\"{chosen_id!r} not among {[c['table_id'] for c in preview.candidate_table_summaries]}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = ingest_document(pdf_path, data_dir, logs_dir, selected_table_id=tid,\n                             max_pdf_pages=P, max_candidate_tables=T)\nexcept ValueError as e:\n    if \"not found in the extracted candidate tables\" in str(e):\n        result = ingest_document(pdf_path, data_dir, logs_dir,\n                                 max_pdf_pages=P, max_candidate_tables=T)  # auto-select primary table\n    else:\n        raise","preventionTips":["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."],"tags":["validation","state-mismatch","pdf","table-extraction","valueerror","python"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}