langflow-ai/langflow · warning · HTTPException

Log retrieval is disabled

Error message

Log retrieval is disabled

What it means

HTTP 501 (Not Implemented) returned by GET /api/v1/logs-stream when the in-process log buffer is disabled — log_buffer.enabled() returns max > 0, i.e. the buffer size (configured via the LANGFLOW_LOG_BUFFER env, default 0 in some deployments) is zero. The endpoint also requires superuser auth, so a 401/403 occurs first for non-superusers.

Source

Thrown at src/backend/base/langflow/api/log_router.py:67

                current_not_sent = 0
                yield "keepalive\n\n"

        await asyncio.sleep(1)


@log_router.get("/logs-stream", dependencies=[Depends(get_current_active_superuser)])
async def stream_logs(
    request: Request,
):
    """HTTP/2 Server-Sent-Event (SSE) endpoint for streaming logs.

    Requires superuser authentication to prevent exposure of sensitive log data.
    It establishes a long-lived connection to the server and receives log messages in real-time.
    The client should use the header "Accept: text/event-stream".
    """
    global log_buffer  # noqa: PLW0602
    if log_buffer.enabled() is False:
        raise HTTPException(
            status_code=HTTPStatus.NOT_IMPLEMENTED,
            detail="Log retrieval is disabled",
        )

    return StreamingResponse(event_generator(request), media_type="text/event-stream")


@log_router.get("/logs", dependencies=[Depends(get_current_active_superuser)])
async def logs(
    lines_before: Annotated[int, Query(description="The number of logs before the timestamp or the last log")] = 0,
    lines_after: Annotated[int, Query(description="The number of logs after the timestamp")] = 0,
    timestamp: Annotated[int, Query(description="The timestamp to start getting logs from")] = 0,
):
    """Retrieve application logs with superuser authentication required.

    SECURITY: Logs may contain sensitive information and require superuser authentication.
    """
    global log_buffer  # noqa: PLW0602

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Start langflow with the log buffer enabled and sized, e.g. LANGFLOW_LOG_BUFFER=1000 (env var controlling the SizedLogBuffer max)
  2. Verify with a plain GET /api/v1/logs — it raises the same 501 if the buffer is disabled
  3. If you use a custom logging config, ensure the SizedLogBuffer handler is attached to the root logger

Example fix

# before
LANGFLOW_LOG_BUFFER=0 uv run langflow run  # /logs-stream -> 501
# after
LANGFLOW_LOG_BUFFER=1000 uv run langflow run  # /logs-stream streams SSE
Defensive patterns

Strategy: validation

Validate before calling

const probe = await fetch('/api/v1/logs', { headers: auth });
if (probe.status === 501) { disableLiveLogUI(); } // buffer off, hide streaming tab

Try / catch

try { const es = new EventSource('/api/v1/logs-stream'); es.onerror = () => fallbackToStdoutLogs(); } catch { fallbackToStdoutLogs(); }

Prevention

When it happens

Trigger: Calling GET /logs-stream with superuser credentials while LANGFLOW_LOG_BUFFER is unset/0, or while running with log buffer disabled (e.g. Uvicorn's default logging setup where the sized buffer is not attached).

Common situations: Default deployments where the sized log buffer is disabled; trying to view live logs in the admin UI without enabling log retention.

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/86163b9021642e99. Report an issue: GitHub.