Zie619/n8n-workflows · error · HTTPException
Insights error: {str(e)}
Error message
Insights error: {str(e)} What it means
A generic 500 from GET /analytics/insights. The handler returns analytics_engine.get_usage_insights() directly; any exception becomes 'Insights error: {str(e)}'. Insight generation usually aggregates usage patterns, so it fails on missing/empty event data or unexpected field shapes in stored events.
Source
Thrown at src/analytics_engine.py:384
raise HTTPException(status_code=500, detail=f"Analytics error: {str(e)}")
@analytics_app.get("/analytics/trends")
async def get_trend_analysis(days: int = Query(30, ge=1, le=365)):
"""Get trend analysis for specified period."""
try:
return analytics_engine.get_trend_analysis(days)
except Exception as e:
raise HTTPException(status_code=500, detail=f"Trend analysis error: {str(e)}")
@analytics_app.get("/analytics/insights")
async def get_usage_insights():
"""Get usage insights and patterns."""
try:
return analytics_engine.get_usage_insights()
except Exception as e:
raise HTTPException(status_code=500, detail=f"Insights error: {str(e)}")
@analytics_app.get("/analytics/dashboard")
async def get_analytics_dashboard():
"""Get analytics dashboard HTML."""
html_content = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>N8N Analytics Dashboard</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #f8f9fa;View on GitHub (pinned to 94007c1445)
Solutions
- Read str(e) from the 500 detail — KeyError names the missing field; JSONDecodeError names the bad row.
- Generate usage events (interact with the API a few times) so insights have input data.
- Recreate or migrate the analytics DB to match the current insights schema.
- If a single corrupted row is the cause, delete or repair rows with invalid JSON metadata.
Defensive patterns
Strategy: try-catch
Try / catch
try:
insights = client.get("/analytics/insights").json()
except HTTPError as e:
if e.response.status_code == 500 and "Insights error" in e.response.text:
insights = {"insights": []} # insights are advisory; UI works without them
else:
raise Prevention
- Treat insights as optional enrichment, never as a dependency of core flows.
- Backfill a small set of usage events on fresh installs so insights code paths are exercised.
- Add schema migrations for the events table so insights never meet unknown columns.
When it happens
Trigger: Calling /analytics/insights before any usage events exist, when the events table lacks columns the insights logic expects (KeyError), or when a JSON payload column contains data that fails to deserialize.
Common situations: New deployment with zero recorded usage; schema drift after upgrading analytics code without migrating stored events; corrupted JSON in event metadata columns.
Related errors
- Analytics error: {str(e)}
- Trend analysis error: {str(e)}
- str(e)
- Error fetching integrations: {str(e)}
- Error searching by category: {str(e)}
AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15).
Data as JSON: /api/errors/016780d3d7dc40ce.
Report an issue: GitHub.