{"record":{"id":"e32243fafaab4e95","repo":"datawhalechina/hello-agents","slug":"str-e-e32243","errorCode":null,"errorMessage":"执行失败: {str(e)}","messagePattern":"执行失败: \\{str\\(e\\)\\}","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"Co-creation-projects/Apricity-InnocoreAI/api/routes/workflow.py","lineNumber":288,"sourceCode":"            paper_url=first_paper[\"url\"],\n            analysis_type=request.analysis_type\n        ))\n        \n        results[\"steps\"].append({\n            \"step\": 2,\n            \"name\": \"分析论文\",\n            \"status\": \"completed\",\n            \"analysis\": analysis_result\n        })\n        \n        results[\"status\"] = \"completed\"\n        return results\n        \n    except HTTPException:\n        raise\n    except Exception as e:\n        logger.error(f\"搜索和分析失败: {str(e)}\")\n        raise HTTPException(status_code=500, detail=f\"执行失败: {str(e)}\")\n\n@router.get(\"/status/{workflow_id}\")\nasync def get_workflow_status(workflow_id: str):\n    \"\"\"获取工作流状态\"\"\"\n    try:\n        # 这里可以实现工作流状态跟踪\n        # 暂时返回模拟状态\n        return {\n            \"workflow_id\": workflow_id,\n            \"status\": \"completed\",\n            \"progress\": 100,\n            \"message\": \"工作流已完成\"\n        }\n    except Exception as e:\n        logger.error(f\"获取工作流状态失败: {str(e)}\")\n        raise HTTPException(status_code=500, detail=str(e))\n","sourceCodeStart":270,"sourceCodeEnd":305,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/Apricity-InnocoreAI/api/routes/workflow.py#L270-L305","documentation":"Catch-all HTTPException 500 '执行失败: {str(e)}' at api/routes/workflow.py:288 for the search-and-analyze route. Raised when the inline call to analyze_paper (imported from api.routes.analysis and invoked directly as a coroutine, bypassing HTTP) throws after search succeeded — e.g. the paper URL is unreachable, the PDF fails to download/parse, or the analysis service errors.","triggerScenarios":"POST /workflow/search-and-analyze where first_paper['url'] is dead, paywalled, or not a PDF; analyze_paper raising because the analysis backend rejects the type; PaperAnalysisRequest validation issues on the URL field.","commonSituations":"Search returns a link-abstract record whose URL requires subscription; PDF is scanned/non-text so parsing fails; direct function-call coupling means changes to analyze_paper's signature break this caller at runtime rather than being caught by route registration.","solutions":["Check the '搜索和分析失败' log for the analyze_paper traceback.","Call POST /analysis directly with the same paper URL to reproduce the analysis failure in isolation.","Guard the URL: skip papers whose URL fails a quick HEAD/availability check and try the next paper.","Loosen coupling by calling the underlying service rather than importing another route handler."],"exampleFix":"// before\nfirst_paper = papers[0]\nanalysis_result = await analyze_paper(PaperAnalysisRequest(paper_url=first_paper[\"url\"], analysis_type=request.analysis_type))\n// after\nfor candidate in papers[:3]:\n    try:\n        analysis_result = await analyze_paper(PaperAnalysisRequest(paper_url=candidate[\"url\"], analysis_type=request.analysis_type))\n        break\n    except Exception:\n        continue\nelse:\n    raise HTTPException(status_code=502, detail=\"候选论文均无法分析\")","handlingStrategy":"try-catch","validationCode":"from urllib.parse import urlparse\ndef is_probably_fetchable(url: str) -> bool:\n    return bool(urlparse(url).scheme in ('http','https') and urlparse(url).netloc)","typeGuard":"def is_probably_fetchable(url: str) -> bool:\n    u = urlparse(url or \"\")\n    return u.scheme in (\"http\", \"https\") and bool(u.netloc)","tryCatchPattern":"try:\n    resp = await client.post(\"/workflow/search-and-analyze\", json=payload, timeout=300)\nexcept httpx.HTTPError:\n    raise\nif resp.status_code >= 500:\n    # analysis of first paper failed; retry after dropping it or pick another\n    payload['skip_urls'] = [first_url]; retry()","preventionTips":["Pre-validate paper URLs client-side (scheme+host at minimum)","Don't assume papers[0] is analyzable; design for fallback candidates","Watch the '搜索和分析失败' server log to see which analysis step broke"],"tags":["fastapi","http-500","pdf-analysis","coupling"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}