{"record":{"id":"1ff42148b76c2fb3","repo":"datawhalechina/hello-agents","slug":"str-e-1ff421","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":304,"sourceCode":"    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":286,"sourceCodeEnd":305,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/Apricity-InnocoreAI/api/routes/workflow.py#L286-L305","documentation":"This error is a catch-all 500 raised by the workflow-status endpoint in api/routes/workflow.py. The endpoint body only builds and returns a hardcoded mock status dict, so the except branch is effectively dead code; if it ever fires it means an unexpected runtime failure (e.g. logger misconfiguration or a refactor that added real logic) escaped the try block. The raw str(e) is leaked to the client, exposing internal details.","triggerScenarios":"Calling GET on the workflow status route (e.g. /workflow/{workflow_id}/status) in any circumstance where the dict construction or logging raises. With the current mock body, practically the only way to trigger it is a broken logger (logger is None) or an injected/modified implementation whose status-tracking code raises (DB connection failure, unknown workflow_id lookup, etc.).","commonSituations":"Developers extend the mock endpoint with real tracking (Redis/DB lookup) that throws; running with a misconfigured logging setup; calling the endpoint with an unexpected workflow_id after validation is added. Also hit during security reviews because the endpoint returns a fake 'completed' status for any id.","solutions":["If you added real status-tracking code inside the try block, catch the specific exceptions (KeyError for unknown workflow_id, ConnectionError for the tracker) instead of a bare Exception","Return a real 404 for unknown workflow_id rather than letting lookups raise","Replace detail=str(e) with a static message such as 'Failed to get workflow status' and log the full traceback server-side","Remove the try/except entirely if you keep the mock body — a dict literal cannot raise"],"exampleFix":"// before\nexcept Exception as e:\n    logger.error(f\"获取工作流状态失败: {str(e)}\")\n    raise HTTPException(status_code=500, detail=str(e))\n\n// after\nexcept KeyError:\n    raise HTTPException(status_code=404, detail=f\"Workflow '{workflow_id}' not found\")\nexcept Exception:\n    logger.exception(\"获取工作流状态失败\")\n    raise HTTPException(status_code=500, detail=\"Failed to get workflow status\")","handlingStrategy":"try-catch","validationCode":"// FastAPI client-side: none needed for the mock; if real tracking added, check id first\nimport requests\nr = requests.get(f'{base}/workflow/{wid}/status')\nif r.status_code == 404: raise KeyError(wid)","typeGuard":null,"tryCatchPattern":"try:\n    resp = client.get_workflow_status(workflow_id)\nexcept HTTPError as e:\n    if e.response.status_code == 404:\n        handle_unknown_workflow(workflow_id)\n    else:\n        raise  # 500: inspect server logs, do not retry blindly","preventionTips":["Do not rely on the mock 'completed' status in production — implement real tracking before integrating","Treat any 500 from this route as a server defect: file it with the logged message instead of retrying","Never forward detail strings from this endpoint to end users; they can contain internal exception text"],"tags":["fastapi","http-500","mock-data","error-handling","information-disclosure"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}