{"record":{"id":"c7f4c42eef22a4f4","repo":"Zie619/n8n-workflows","slug":"error-fetching-integrations-str-e","errorCode":null,"errorMessage":"Error fetching integrations: {str(e)}","messagePattern":"Error fetching integrations: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api_server.py","lineNumber":624,"sourceCode":"        try:\n            db.index_all_workflows(force_reindex=force)\n            print(f\"Reindexing completed successfully (requested by {client_ip})\")\n        except Exception as e:\n            print(f\"Error during reindexing: {e}\")\n\n    background_tasks.add_task(run_indexing)\n    return {\"message\": \"Reindexing started in background\", \"requested_by\": client_ip}\n\n\n@app.get(\"/api/integrations\")\nasync def get_integrations():\n    \"\"\"Get list of all unique integrations.\"\"\"\n    try:\n        stats = db.get_stats()\n        # For now, return basic info. Could be enhanced to return detailed integration stats\n        return {\"integrations\": [], \"count\": stats[\"unique_integrations\"]}\n    except Exception as e:\n        raise HTTPException(\n            status_code=500, detail=f\"Error fetching integrations: {str(e)}\"\n        )\n\n\n@app.get(\"/api/categories\")\nasync def get_categories():\n    \"\"\"Get available workflow categories for filtering.\"\"\"\n    try:\n        # Try to load from the generated unique categories file\n        categories_file = Path(\"context/unique_categories.json\")\n        if categories_file.exists():\n            with open(categories_file, \"r\", encoding=\"utf-8\") as f:\n                categories = json.load(f)\n            return {\"categories\": categories}\n        else:\n            # Fallback: extract categories from search_categories.json\n            search_categories_file = Path(\"context/search_categories.json\")\n            if search_categories_file.exists():","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/api_server.py#L606-L642","documentation":"A generic 500 from the /api/integrations endpoint. The handler calls db.get_stats() and wraps any exception with the message 'Error fetching integrations: {str(e)}'. The endpoint itself only returns counts (the integrations list is hardcoded empty), so the real failure is always inside get_stats() — typically SQLite/database access.","triggerScenarios":"GET /api/integrations when the SQLite database file does not exist, is locked by another writer, has a missing/corrupt stats table (e.g. created by an older schema version), or when db was never initialized because indexing never ran.","commonSituations":"Fresh clone where scripts/create_db.py (or equivalent indexing step) was never run; the server's working directory differs from the one containing the .db file so the relative path resolves nowhere; concurrent reindex writing the DB while stats are read; schema drift after upgrading the code without re-running migrations.","solutions":["Run the database indexing/bootstrap step once so the DB and its stats tables exist, then retry GET /api/integrations.","Check the server logs for the underlying exception text appended after 'Error fetching integrations:' — it names the exact SQLite error (no such table, unable to open database file, database is locked).","Verify the server is started from the directory the DB path is relative to, or make the DB path absolute via config/env var.","If 'database is locked', stop concurrent writers or enable WAL mode on the SQLite file."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"from pathlib import Path\n\ndef db_ready(db_path: str = \"workflows.db\") -> bool:\n    p = Path(db_path)\n    return p.exists() and p.stat().st_size > 0","typeGuard":null,"tryCatchPattern":"try:\n    data = client.get(\"/api/integrations\").json()\nexcept (ConnectionError, TimeoutError):\n    raise  # transport issues, not this error\nexcept HTTPError as e:\n    if e.response.status_code == 500 and \"Error fetching integrations\" in e.response.text:\n        # degrade gracefully: counts are optional metadata\n        data = {\"integrations\": [], \"count\": 0}\n    else:\n        raise","preventionTips":["Run the DB bootstrap/indexing step as part of deployment before serving traffic.","Use an absolute DB path from config so cwd changes cannot break resolution.","Enable SQLite WAL mode to avoid locked-database 500s during concurrent reindexing."],"tags":["http-500","sqlite","database","fastapi","initialization"],"backgroundTag":null,"analyzedSha":"94007c1445d9258a7da116646b79473e7c7c3282","analyzedAt":"2026-08-15T04:10:37.591Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}