Zie619/n8n-workflows · error · HTTPException
Error searching workflows: {str(e)}
Error message
Error searching workflows: {str(e)} What it means
A 500 response from GET /api/workflows when the paginated search pipeline fails. The handler calls db.search_workflows(...) and result construction inside one try block; any exception from the query engine (bad query syntax, missing table, DB connection error) is converted to HTTPException(500) containing str(e).
Source
Thrown at api_server.py:303
continue
pages = (total + per_page - 1) // per_page # Ceiling division
return SearchResponse(
workflows=workflow_summaries,
total=total,
page=page,
per_page=per_page,
pages=pages,
query=q,
filters={
"trigger": trigger,
"complexity": complexity,
"active_only": active_only,
},
)
except Exception as e:
raise HTTPException(
status_code=500, detail=f"Error searching workflows: {str(e)}"
)
@app.get("/api/workflows/{filename}")
async def get_workflow_detail(filename: str, request: Request):
"""Get detailed workflow information including raw JSON."""
try:
# Security: Validate filename to prevent path traversal
if not validate_filename(filename):
print(f"Security: Blocked path traversal attempt for filename: {filename}")
raise HTTPException(status_code=400, detail="Invalid filename format")
# Security: Rate limiting
client_ip = request.client.host if request.client else "unknown"
if not check_rate_limit(client_ip):
raise HTTPException(
status_code=429, detail="Rate limit exceeded. Please try again later."View on GitHub (pinned to 94007c1445)
Solutions
- Retry the request with an empty q parameter to see whether the query text or the database is at fault.
- Verify the database is built and current by checking GET /api/stats; rebuild via the reindex flow if stats also fail.
- Strip or escape double quotes from user-supplied q before it reaches the search parser.
- Read the server log: the detail field carries the exact exception message from db.search_workflows.
Example fix
# before
results, total = db.search_workflows(q, ...)
# after (sanitize quotes that break the query parser)
safe_q = q.replace('"', "'")
results, total = db.search_workflows(safe_q, ...) Defensive patterns
Strategy: try-catch
Validate before calling
def safe_query(q: str) -> str:
# strip characters the search parser treats specially
return q.replace('"', '').replace(':', ' ') Try / catch
try:
resp = client.get('/api/workflows', params={'q': q})
resp.raise_for_status()
except HTTPError as e:
if e.response.status_code == 500:
retry_with_empty_q_or_report(e.response.json().get('detail')) Prevention
- Sanitize user-supplied q (remove quotes/colons) before sending.
- Fall back to an empty query on 500 to distinguish parser issues from DB issues.
- Monitor server logs — the detail string embeds the root exception.
When it happens
Trigger: GET /api/workflows?q=... where the query string breaks the DB-side search parser (e.g. unmatched quotes producing filename:"...-style phrases), calling the endpoint against a missing/corrupt SQLite database, or page/per_page edge values that trip arithmetic on None totals.
Common situations: Typing a stray double-quote in the UI search box (the detail endpoint itself builds f'filename:"{filename}"' queries); switching database files mid-run; schema drift between the indexer and the query code after a partial upgrade.
Related errors
- Error fetching stats: {str(e)}
- Workflow not found in database
- Error fetching integrations: {str(e)}
- Error searching by category: {str(e)}
- {str(e)}
AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15).
Data as JSON: /api/errors/69de5c524022b96f.
Report an issue: GitHub.