{"record":{"id":"1c9377bd6a6c4d31","repo":"datawhalechina/hello-agents","slug":"error-1c9377","errorCode":null,"errorMessage":"未找到相关论文","messagePattern":"未找到相关论文","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"Co-creation-projects/Apricity-InnocoreAI/api/routes/workflow.py","lineNumber":66,"sourceCode":"            search_result = await search_papers(PaperSearchRequest(\n                keywords=request.keywords,\n                source=\"arxiv\",\n                limit=request.limit\n            ))\n            \n            papers = search_result.get(\"papers\", [])\n            results[\"steps\"].append({\n                \"step\": 1,\n                \"name\": \"Hunter - 论文搜索\",\n                \"status\": \"completed\",\n                \"result\": {\n                    \"total_found\": len(papers),\n                    \"papers\": papers\n                }\n            })\n            \n            if not papers:\n                raise HTTPException(status_code=404, detail=\"未找到相关论文\")\n            \n        except Exception as e:\n            logger.error(f\"论文搜索失败: {str(e)}\")\n            results[\"steps\"].append({\n                \"step\": 1,\n                \"name\": \"Hunter - 论文搜索\",\n                \"status\": \"failed\",\n                \"error\": str(e)\n            })\n            results[\"status\"] = \"failed\"\n            return results\n        \n        # 步骤 2: Miner - 分析每篇论文\n        logger.info(f\"[工作流 {workflow_id}] 步骤 2/4: 分析论文\")\n        analyses = []\n        try:\n            from api.routes.analysis import analyze_paper, PaperAnalysisRequest\n            ","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/Apricity-InnocoreAI/api/routes/workflow.py#L48-L84","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nif not papers:\n    raise HTTPException(status_code=404, detail=\"未找到相关论文\")\nexcept Exception as e:\n    ...swallows the 404...\n// after\nif not papers:\n    results[\"status\"] = \"completed\"\n    results[\"steps\"].append({\"step\": 1, \"name\": \"Hunter - 论文搜索\", \"status\": \"completed\", \"result\": {\"total_found\": 0, \"papers\": []}})\n    return results\n# and in except:\nexcept HTTPException:\n    raise\nexcept Exception as e:\n    ...","handlingStrategy":"fallback","validationCode":"if not keywords or len(keywords.strip()) < 3:\n    raise ValueError('keywords too narrow')\n# widen before submitting","typeGuard":"def has_papers(step: dict) -> bool:\n    r = step.get(\"result\", {})\n    return r.get(\"total_found\", 0) > 0","tryCatchPattern":"try:\n    results = await client.post(\"/workflow/full\", json=payload).json()\nexcept httpx.HTTPError:\n    raise\nif any(s.get(\"status\") == \"failed\" for s in results.get(\"steps\", [])):\n    broaden_keywords_and_retry()","preventionTips":["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"],"tags":["fastapi","http-404","empty-results","exception-swallowing"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}