langflow-ai/langflow · error · HTTPException
str(exc)
Error message
str(exc)
What it means
Raised by GET /api/v1/api_keys/ as a catch-all: any unexpected exception while listing the current user's API keys (database errors, ORM issues, deserialization problems) is converted to HTTP 400 with the raw exception text as detail. It requires an authenticated user (CurrentActiveUser), so 401 happens earlier at the dependency. The 400 status is misleading for server-side faults but the detail string usually names the real cause.
Source
Thrown at src/backend/base/langflow/api/v1/api_key.py:27
# Assuming you have these methods in your service layer
from langflow.services.database.models.api_key.crud import create_api_key, delete_api_key, get_api_keys
from langflow.services.database.models.api_key.model import ApiKeyCreate, UnmaskedApiKeyRead
from langflow.services.deps import get_settings_service
router = APIRouter(tags=["APIKey"], prefix="/api_key")
@router.get("/", include_in_schema=False)
async def get_api_keys_route(
db: DbSession,
current_user: CurrentActiveUser,
) -> ApiKeysResponse:
try:
user_id = current_user.id
api_keys = await get_api_keys(db, user_id)
return ApiKeysResponse(total_count=len(api_keys), user_id=user_id, api_keys=api_keys)
except Exception as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
@router.post("/", include_in_schema=False)
async def create_api_key_route(
req: ApiKeyCreate,
current_user: CurrentActiveUser,
db: DbSession,
) -> UnmaskedApiKeyRead:
try:
user_id = current_user.id
return await create_api_key(db, req, user_id=user_id)
except PermissionError as e:
raise HTTPException(status_code=403, detail=str(e)) from e
except Exception as e:
raise HTTPException(status_code=400, detail=str(e)) from e
@router.delete("/{api_key_id}", include_in_schema=False)View on GitHub (pinned to 976ec789d2)
Solutions
- Read the detail string — it contains the underlying exception message; fix that root cause
- Run migrations (make alembic-upgrade) if the error mentions missing columns/tables
- Verify DB connectivity and that the api_key table matches the current model; restart after fixing
Defensive patterns
Strategy: try-catch
Try / catch
try:
keys = client.get("/api/v1/api_keys/").json()
except HTTPStatusError as e:
if e.response.status_code == 400:
log.error("api_keys listing failed: %s", e.response.json().get("detail"))
alert_ops("api_keys route degraded") # usually a backend/DB fault, not client error
raise
raise Prevention
- Treat 400 from this read-only listing as a server-side signal — inspect detail, don't mutate the request
- Run alembic upgrades before pointing clients at a new backend
- Monitor this route; it should never fail on a healthy deployment
When it happens
Trigger: GET /api/v1/api_keys/ when the underlying get_api_keys call throws — DB connectivity loss, schema mismatch after a partial migration, or an unexpected value in the api_key table.
Common situations: DB migration drift where the api_key table shape doesn't match the ORM model; transient database outage surfacing as 400; running a frontend built against a newer API than the backend.
Related errors
- No model provider is configured. Please configure at least o
- Missing required configuration for {provider}: {', '.join(mi
- Failed to download flows: ${response.statusText}
- Failed to install MCP
- No supported files found in folder. Allowed types: ${types?.
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/f25bea9a27dbd9e2.
Report an issue: GitHub.