Zie619/n8n-workflows · error · HTTPException

Assistant error: {str(e)}

Error message

Assistant error: {str(e)}

What it means

A generic 500 from the AI assistant chat endpoint (ai_app). The handler runs the assistant pipeline (response generation, suggestions, confidence calculation) and wraps any failure as 'Assistant error: {str(e)}'. Failures usually originate in the LLM/assistant backend: missing API keys, model timeouts, or malformed workflow data passed into calculate_confidence.

Source

Thrown at src/ai_assistant.py:280

        # Generate response
        response_text = assistant.generate_response(message.message, workflows)

        # Get suggestions
        suggestions = assistant.get_suggestions(message.message)

        # Calculate confidence
        confidence = assistant.calculate_confidence(message.message, workflows)

        return AIResponse(
            response=response_text,
            workflows=workflows,
            suggestions=suggestions,
            confidence=confidence,
        )

    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Assistant error: {str(e)}")


@ai_app.get("/chat/interface")
async def chat_interface():
    """Get the chat interface 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 AI Assistant</title>
        <style>
            * { margin: 0; padding: 0; box-sizing: border-box; }
            body { 
                font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                height: 100vh;

View on GitHub (pinned to 94007c1445)

Solutions

  1. Read the str(e) suffix in the 500 detail — it is the underlying assistant exception (auth error, timeout, KeyError) and points at the failing stage.
  2. Verify required LLM/env credentials are present in the server process and that a minimal assistant call works standalone.
  3. If the error names calculate_confidence or suggestions, re-index the workflow DB so the data shape matches what the assistant expects.
  4. Pin/align the assistant dependency versions and retry after restart.
Defensive patterns

Strategy: try-catch

Validate before calling

import os

def assistant_config_ready() -> bool:
    # adjust key names to the assistant backend actually used
    return bool(os.environ.get("OPENAI_API_KEY") or os.environ.get("ANTHROPIC_API_KEY"))

Try / catch

try:
    result = client.post("/ai/chat", json={"message": msg}).json()
except HTTPError as e:
    if e.response.status_code == 500 and "Assistant error" in e.response.text:
        # LLM backends fail transiently (rate limit, timeout): one bounded retry is reasonable
        result = client.post("/ai/chat", json={"message": msg}).json()
    else:
        raise

Prevention

When it happens

Trigger: POST to the AI chat endpoint with a message when the assistant's LLM provider key is missing/invalid, the model call times out or rate-limits, or the workflows list handed to calculate_confidence contains unexpected shapes raising inside the try block.

Common situations: OPENAI/LLM API key not set in the server environment; expired quota or network egress blocked from the server; assistant library version changed its internal API after a dependency update; empty workflow index making downstream processing fail.

Related errors


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