Zie619/n8n-workflows · error · HTTPException

{str(e)}

Error message

{str(e)}

What it means

A generic 500 from GET /api/v2/workflows (enhanced search listing) in enhanced_api.py. The handler times the query and returns a workflow list; any exception in _search_workflows_enhanced or DB connection setup is re-raised with detail=str(e), exposing the raw underlying error.

Source

Thrown at src/enhanced_api.py:125

                    sort_by=sort_by,
                    sort_order=sort_order,
                    limit=limit,
                    offset=offset,
                )

                response_time = (time.time() - start_time) * 1000

                return {
                    "workflows": workflows,
                    "total": len(workflows),
                    "limit": limit,
                    "offset": offset,
                    "response_time_ms": round(response_time, 2),
                    "timestamp": datetime.now().isoformat(),
                }

            except Exception as e:
                raise HTTPException(status_code=500, detail=str(e))

        @self.app.post("/api/v2/workflows/search")
        async def advanced_workflow_search(request: WorkflowSearchRequest):
            """Advanced workflow search with complex queries"""
            start_time = time.time()

            try:
                results = self._advanced_search(request)
                response_time = (time.time() - start_time) * 1000

                return {
                    "results": results,
                    "total": len(results),
                    "query": request.dict(),
                    "response_time_ms": round(response_time, 2),
                    "timestamp": datetime.now().isoformat(),
                }

View on GitHub (pinned to 94007c1445)

Solutions

  1. Read the detail field — it contains the literal SQLite/Python error (e.g. 'no such column: w.foo').
  2. Create/point to the correct database: run the bootstrap script or fix the db_path used by EnhancedAPI.
  3. Remove or correct unsupported filter/sort parameters and retry with a bare call.
  4. If 'database is locked', reduce concurrent writers or enable WAL journaling.
Defensive patterns

Strategy: try-catch

Validate before calling

from pathlib import Path

def enhanced_db_ready(db_path: str) -> bool:
    return Path(db_path).exists() and Path(db_path).stat().st_size > 0

Try / catch

try:
    data = client.get("/api/v2/workflows", params=filters).json()
except HTTPError as e:
    if e.response.status_code == 500:
        # strip filters to isolate the offending parameter, then retry once bare
        data = client.get("/api/v2/workflows").json()
    else:
        raise

Prevention

When it happens

Trigger: Calling /api/v2/workflows with filters when the SQLite DB file is absent, a filter references an unknown column, or the dynamic query builder composes invalid SQL from unexpected query parameters (e.g. sort=invalid_field).

Common situations: DB never created on fresh setup; filter/sort parameter names drifted from the schema after an update; relative db_path resolved from the wrong cwd; DB locked by concurrent writes.

Related errors


AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15). Data as JSON: /api/errors/4f8324cabe4a111b. Report an issue: GitHub.