datawhalechina/hello-agents · error · HTTPException
执行失败: {str(e)}
Error message
执行失败: {str(e)} What it means
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.
Source
Thrown at Co-creation-projects/Apricity-InnocoreAI/api/routes/workflow.py:288
paper_url=first_paper["url"],
analysis_type=request.analysis_type
))
results["steps"].append({
"step": 2,
"name": "分析论文",
"status": "completed",
"analysis": analysis_result
})
results["status"] = "completed"
return results
except HTTPException:
raise
except Exception as e:
logger.error(f"搜索和分析失败: {str(e)}")
raise HTTPException(status_code=500, detail=f"执行失败: {str(e)}")
@router.get("/status/{workflow_id}")
async def get_workflow_status(workflow_id: str):
"""获取工作流状态"""
try:
# 这里可以实现工作流状态跟踪
# 暂时返回模拟状态
return {
"workflow_id": workflow_id,
"status": "completed",
"progress": 100,
"message": "工作流已完成"
}
except Exception as e:
logger.error(f"获取工作流状态失败: {str(e)}")
raise HTTPException(status_code=500, detail=str(e))
View on GitHub (pinned to 606a07d341)
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.
Example fix
// before
first_paper = papers[0]
analysis_result = await analyze_paper(PaperAnalysisRequest(paper_url=first_paper["url"], analysis_type=request.analysis_type))
// after
for candidate in papers[:3]:
try:
analysis_result = await analyze_paper(PaperAnalysisRequest(paper_url=candidate["url"], analysis_type=request.analysis_type))
break
except Exception:
continue
else:
raise HTTPException(status_code=502, detail="候选论文均无法分析") Defensive patterns
Strategy: try-catch
Validate before calling
from urllib.parse import urlparse
def is_probably_fetchable(url: str) -> bool:
return bool(urlparse(url).scheme in ('http','https') and urlparse(url).netloc) Type guard
def is_probably_fetchable(url: str) -> bool:
u = urlparse(url or "")
return u.scheme in ("http", "https") and bool(u.netloc) Try / catch
try:
resp = await client.post("/workflow/search-and-analyze", json=payload, timeout=300)
except httpx.HTTPError:
raise
if resp.status_code >= 500:
# analysis of first paper failed; retry after dropping it or pick another
payload['skip_urls'] = [first_url]; retry() Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/e32243fafaab4e95.
Report an issue: GitHub.