datawhalechina/hello-agents · warning · HTTPException
未找到相关论文
Error message
未找到相关论文
What it means
HTTPException 404 '未找到相关论文' at api/routes/workflow.py:66 inside the full workflow's step 1 (Hunter paper search). The search succeeded structurally but returned zero papers for the given keywords/limit, and the endpoint treats 'no results' as a 404 rather than an empty result set. Note the surrounding except Exception actually catches and swallows this HTTPException into the failed-step path, so behavior depends on which handler wins.
Source
Thrown at Co-creation-projects/Apricity-InnocoreAI/api/routes/workflow.py:66
search_result = await search_papers(PaperSearchRequest(
keywords=request.keywords,
source="arxiv",
limit=request.limit
))
papers = search_result.get("papers", [])
results["steps"].append({
"step": 1,
"name": "Hunter - 论文搜索",
"status": "completed",
"result": {
"total_found": len(papers),
"papers": papers
}
})
if not papers:
raise HTTPException(status_code=404, detail="未找到相关论文")
except Exception as e:
logger.error(f"论文搜索失败: {str(e)}")
results["steps"].append({
"step": 1,
"name": "Hunter - 论文搜索",
"status": "failed",
"error": str(e)
})
results["status"] = "failed"
return results
# 步骤 2: Miner - 分析每篇论文
logger.info(f"[工作流 {workflow_id}] 步骤 2/4: 分析论文")
analyses = []
try:
from api.routes.analysis import analyze_paper, PaperAnalysisRequest
View on GitHub (pinned to 606a07d341)
Solutions
- Broaden keywords, remove filters, or raise limit, then retry.
- Test the same query against the underlying search API directly to confirm zero results is genuine.
- Decide the contract: return 200 with an empty steps result instead of 404 for 'no papers', since 404 implies a missing resource.
- Fix the exception flow: the generic except Exception here catches HTTPException, defeating the intended 404 — re-raise HTTPException first.
Example fix
// before
if not papers:
raise HTTPException(status_code=404, detail="未找到相关论文")
except Exception as e:
...swallows the 404...
// after
if not papers:
results["status"] = "completed"
results["steps"].append({"step": 1, "name": "Hunter - 论文搜索", "status": "completed", "result": {"total_found": 0, "papers": []}})
return results
# and in except:
except HTTPException:
raise
except Exception as e:
... Defensive patterns
Strategy: fallback
Validate before calling
if not keywords or len(keywords.strip()) < 3:
raise ValueError('keywords too narrow')
# widen before submitting Type guard
def has_papers(step: dict) -> bool:
r = step.get("result", {})
return r.get("total_found", 0) > 0 Try / catch
try:
results = await client.post("/workflow/full", json=payload).json()
except httpx.HTTPError:
raise
if any(s.get("status") == "failed" for s in results.get("steps", [])):
broaden_keywords_and_retry() Prevention
- Send 2-3 broad keywords rather than one hyper-specific phrase
- Handle both shapes: 404 and status='failed' with empty papers
- Test keywords against the underlying search API first
When it happens
Trigger: POST /workflow/full with overly narrow keywords, filters excluding everything, or limit=0; upstream search API returning an empty papers list; malformed query that yields no matches.
Common situations: Typo'd or hyper-specific Chinese/English keyword mixes the academic API can't match; region or date filters too strict; upstream API silently degraded returning empty instead of erroring.
Related errors
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/1c9377bd6a6c4d31.
Report an issue: GitHub.