{"record":{"id":"829a83d74ca615c2","repo":"Zie619/n8n-workflows","slug":"workflow-not-found","errorCode":null,"errorMessage":"Workflow not found","messagePattern":"Workflow not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"src/enhanced_api.py","lineNumber":161,"sourceCode":"\n            except Exception as e:\n                raise HTTPException(status_code=500, detail=str(e))\n\n        @self.app.get(\"/api/v2/workflows/{workflow_id}\")\n        async def get_workflow_enhanced(\n            workflow_id: str,\n            include_stats: bool = Query(True),\n            include_ratings: bool = Query(True),\n            include_related: bool = Query(True),\n        ):\n            \"\"\"Get detailed workflow information\"\"\"\n            try:\n                workflow_data = self._get_workflow_details(\n                    workflow_id, include_stats, include_ratings, include_related\n                )\n\n                if not workflow_data:\n                    raise HTTPException(status_code=404, detail=\"Workflow not found\")\n\n                return workflow_data\n\n            except Exception as e:\n                raise HTTPException(status_code=500, detail=str(e))\n\n        # Recommendation endpoints\n        @self.app.post(\"/api/v2/recommendations\")\n        async def get_workflow_recommendations(request: WorkflowRecommendationRequest):\n            \"\"\"Get personalized workflow recommendations\"\"\"\n            try:\n                recommendations = self._get_recommendations(request)\n                return {\n                    \"recommendations\": recommendations,\n                    \"user_profile\": request.dict(),\n                    \"timestamp\": datetime.now().isoformat(),\n                }\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/src/enhanced_api.py#L143-L179","documentation":"A 404 raised by GET /api/v2/workflows/{workflow_id} when _get_workflow_details returns falsy. Important caveat: the 404 HTTPException is raised INSIDE the try block, and the following 'except Exception' catches HTTPException too (it subclasses Exception), so the intended 404 is usually re-wrapped into a 500 with detail like '404: Workflow not found'. The 404 only survives if the re-wrap code path differs.","triggerScenarios":"Requesting a workflow id that does not exist in the DB (deleted, never indexed, wrong id format). Because of the over-broad except, the client often receives 500 instead of 404 for exactly the same condition.","commonSituations":"Stale workflow id from an old search index after reindexing changed ids; typo or URL-encoded id mismatch; fresh DB where nothing is indexed yet.","solutions":["Verify the id exists first via GET /api/v2/workflows (listing/search) and copy the exact id.","Re-index the DB so ids in the index match what this endpoint serves.","Fix the handler bug: re-raise HTTPException before the generic except (except HTTPException: raise / except Exception: ...).","On the client, treat both 404 and a 500 containing 'Workflow not found' as not-found for now."],"exampleFix":"# before\n            try:\n                workflow_data = self._get_workflow_details(...)\n                if not workflow_data:\n                    raise HTTPException(status_code=404, detail=\"Workflow not found\")\n                return workflow_data\n            except Exception as e:\n                raise HTTPException(status_code=500, detail=str(e))\n\n# after\n            try:\n                workflow_data = self._get_workflow_details(...)\n                if not workflow_data:\n                    raise HTTPException(status_code=404, detail=\"Workflow not found\")\n                return workflow_data\n            except HTTPException:\n                raise\n            except Exception as e:\n                raise HTTPException(status_code=500, detail=str(e))","handlingStrategy":"validation","validationCode":"known_ids = {w[\"id\"] for w in client.get(\"/api/v2/workflows\", params={\"limit\": 1000}).json()[\"workflows\"]}\n\ndef workflow_exists(workflow_id: str) -> bool:\n    return workflow_id in known_ids","typeGuard":null,"tryCatchPattern":"try:\n    resp = client.get(f\"/api/v2/workflows/{workflow_id}\")\n    resp.raise_for_status()\n    detail = resp.json()\nexcept HTTPError as e:\n    body = e.response.text\n    if e.response.status_code == 404 or \"Workflow not found\" in body:\n        raise KeyError(f\"workflow {workflow_id!r} not found\") from e\n    raise","preventionTips":["Always source ids from a fresh listing/search, never from cached URLs.","Handle both 404 and the 500-wrapped '404: Workflow not found' until the handler bug is fixed.","Fix the server: add 'except HTTPException: raise' before the generic except."],"tags":["http-404","http-500","exception-handling","fastapi","bug"],"backgroundTag":null,"analyzedSha":"94007c1445d9258a7da116646b79473e7c7c3282","analyzedAt":"2026-08-15T04:10:37.591Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}