langflow-ai/langflow · warning · HTTPException

Timestamp is required when requesting logs after the timesta

Error message

Timestamp is required when requesting logs after the timestamp

What it means

HTTP 400 from GET /api/v1/logs when lines_after > 0 but no timestamp (or timestamp <= 0) is provided. Paging forward through logs requires an anchor point; without a timestamp the server cannot determine what 'after' means.

Source

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

):
    """Retrieve application logs with superuser authentication required.

    SECURITY: Logs may contain sensitive information and require superuser authentication.
    """
    global log_buffer  # noqa: PLW0602
    if log_buffer.enabled() is False:
        raise HTTPException(
            status_code=HTTPStatus.NOT_IMPLEMENTED,
            detail="Log retrieval is disabled",
        )
    if lines_after > 0 and lines_before > 0:
        raise HTTPException(
            status_code=HTTPStatus.BAD_REQUEST,
            detail="Cannot request logs before and after the timestamp",
        )
    if timestamp <= 0:
        if lines_after > 0:
            raise HTTPException(
                status_code=HTTPStatus.BAD_REQUEST,
                detail="Timestamp is required when requesting logs after the timestamp",
            )
        content = log_buffer.get_last_n(10) if lines_before <= 0 else log_buffer.get_last_n(lines_before)
    elif lines_before > 0:
        content = log_buffer.get_before_timestamp(timestamp=timestamp, lines=lines_before)
    elif lines_after > 0:
        content = log_buffer.get_after_timestamp(timestamp=timestamp, lines=lines_after)
    else:
        content = log_buffer.get_before_timestamp(timestamp=timestamp, lines=10)
    return JSONResponse(content=content)

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Include a positive timestamp when using lines_after, e.g. take the ts of the last displayed log line
  2. If you want the most recent logs, use lines_before (or no params for the last 10) instead
  3. Cache the timestamp of the newest line seen and pass it for the next forward page

Example fix

# before
GET /api/v1/logs?lines_after=20  # 400
# after
GET /api/v1/logs?timestamp=1712345678&lines_after=20
Defensive patterns

Strategy: validation

Validate before calling

function logQuery({ timestamp = 0, before = 0, after = 0 }) {
  if (after > 0 && !(timestamp > 0)) throw new Error('timestamp required for lines_after');
  return { timestamp, lines_before: before, lines_after: after };
}

Type guard

const isValidForwardQuery = (q) => q.lines_after <= 0 || q.timestamp > 0;

Prevention

When it happens

Trigger: Calling /api/v1/logs?lines_after=20 with timestamp omitted or set to 0.

Common situations: Log viewer 'load more' buttons that paginate forward but drop the timestamp parameter; default client SDKs sending 0-initialized timestamps.

Related errors


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