{"record":{"id":"9bec38cc4542898a","repo":"HKUDS/DeepTutor","slug":"conceptdesignagent-prompts-are-not-configured","errorCode":null,"errorMessage":"ConceptDesignAgent prompts are not configured.","messagePattern":"ConceptDesignAgent prompts are not configured\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/agents/math_animator/agents/concept_design_agent.py","lineNumber":42,"sourceCode":"            agent_name=\"concept_design_agent\",\n            api_key=api_key,\n            base_url=base_url,\n            api_version=api_version,\n            language=language,\n        )\n\n    async def process(\n        self,\n        *,\n        user_input: str,\n        output_mode: str,\n        analysis: ConceptAnalysis,\n        style_hint: str,\n    ) -> SceneDesign:\n        system_prompt = self.get_prompt(\"system\")\n        user_template = self.get_prompt(\"user_template\")\n        if not system_prompt or not user_template:\n            raise ValueError(\"ConceptDesignAgent prompts are not configured.\")\n\n        user_prompt = user_template.format(\n            user_input=user_input.strip(),\n            output_mode=output_mode,\n            style_hint=style_hint.strip() or \"(none)\",\n            analysis_json=json.dumps(analysis.model_dump(), ensure_ascii=False, indent=2),\n        )\n        _chunks: list[str] = []\n        async for _c in self.stream_llm(\n            user_prompt=user_prompt,\n            system_prompt=system_prompt,\n            response_format={\"type\": \"json_object\"},\n            stage=\"concept_design\",\n            trace_meta=build_trace_metadata(\n                call_id=new_call_id(\"math-design\"),\n                phase=\"concept_design\",\n                label=\"Concept design\",\n                call_kind=\"math_concept_design\",","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/agents/math_animator/agents/concept_design_agent.py#L24-L60","documentation":"Catch-all in _extract_pdf: any unexpected exception from pypdf while reading pages is wrapped in CorruptDocumentError with the underlying message appended. It signals a malformed or unreadable PDF rather than a specific known condition.","triggerScenarios":"pypdf throws ValueError ('stream has ended unexpectedly'), structural errors on truncated PDFs, or AssertionError on malformed xref tables while enumerating reader.pages.","commonSituations":"Truncated uploads (interrupted transfers), corrupted email attachments, hand-crafted or PDFs written by buggy generators.","solutions":["Repair the PDF first: qpdf --decrypt or Ghostscript can rebuild broken xref tables","Re-download/re-upload the file if it was truncated","Install pymupdf — fitz is tried first and tolerates many malformed PDFs pypdf rejects"],"exampleFix":"// before\ntext = extract_text_from_bytes(corrupted, filename=\"bad.pdf\")\n\n// after\nimport subprocess\ntmp = \"/tmp/bad.pdf\"; open(tmp,\"wb\").write(corrupted)\nsubprocess.run([\"qpdf\", \"--decrypt\", tmp, \"/tmp/fixed.pdf\"], check=True)\ntext = extract_text_from_bytes(open(\"/tmp/fixed.pdf\",\"rb\").read(), filename=\"bad.pdf\")","handlingStrategy":"fallback","validationCode":"import fitz\ntry:\n    with fitz.open(stream=data, filetype=\"pdf\") as doc:\n        doc.page_count  # forces full open; fitz tolerates many broken PDFs\nexcept Exception:\n    repair_or_reject(fn)","typeGuard":null,"tryCatchPattern":"except CorruptDocumentError as e:\n    if \"failed to read PDF\" in str(e):\n        repaired = qpdf_repair(data)\n        if repaired:\n            text = extract_text_from_bytes(repaired, filename=fn)","preventionTips":["Verify upload completeness (content-length vs actual bytes)","Repair malformed PDFs with qpdf/Ghostscript before extraction"],"tags":["pdf","corruption","pypdf","document-extraction"],"backgroundTag":"corrupt-pdf-parse","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}