{"record":{"id":"6d3003f1bbf0c35a","repo":"open-webui/open-webui","slug":"error-messages-default-6d3003","errorCode":null,"errorMessage":"ERROR_MESSAGES.DEFAULT()","messagePattern":"ERROR_MESSAGES\\.DEFAULT\\(\\)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"backend/open_webui/routers/chats.py","lineNumber":259,"sourceCode":"                sort_by=sort_by,\n                sort_dir=sort_dir,\n                skip=skip,\n                limit=limit,\n                db=db,\n            )\n        else:\n            chats = await Chats.get_chat_title_id_list_by_user_id(\n                user.id,\n                include_folders=include_folders,\n                include_pinned=include_pinned,\n                sort_by=sort_by,\n                sort_dir=sort_dir,\n                db=db,\n            )\n        return await add_active_state_to_chat_list(request, chats)\n    except Exception as e:\n        log.exception(e)\n        raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT())\n\n\n@router.post('/read')\nasync def mark_chats_read_by_user_id(\n    user=Depends(get_verified_user),\n    db: AsyncSession = Depends(get_async_session),\n):\n    return {\n        'updated_count': await Chats.mark_chats_read_by_user_id(user.id, db=db),\n        'folder_unread_counts': await get_folder_unread_counts(user.id, db=db),\n    }\n\n\n############################\n# GetChatUsageStats\n# EXPERIMENTAL: may be removed in future releases\n############################\n","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/open-webui/open-webui/blob/01f4282f1ffe0d6212f58d3afbeae21fffd0c4be/backend/open_webui/routers/chats.py#L241-L277","documentation":"Catch-all 400 from the user chat-list endpoint (GET /api/v1/chats/ with pagination/sort params). Any exception while querying or post-processing the list — invalid query parameter combinations, DB session failure — is logged and converted to this generic 400.","triggerScenarios":"Calling the chat list with malformed sort_by/sort_dir/include_pinned/include_folders values, or a page/size the handler mishandles; DB connectivity errors during the listing query.","commonSituations":"Client upgraded and sending new sort params an older backend rejects; negative or zero page values; transient DB outage making every list call fail this way.","solutions":["Inspect the server log line produced by log.exception(e) — the response itself carries no cause","Simplify the request to bare GET /api/v1/chats/ and re-add parameters one at a time to find the offender","Validate page >= 1 and known sort_by/sort_dir enum values on the client","If bare calls also fail, investigate database health rather than parameters"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const clamp = (v, lo, hi) => Math.min(Math.max(Number(v) || lo, lo), hi);\nparams.page = clamp(params.page, 1, 1e6);","typeGuard":null,"tryCatchPattern":"catch (e) { if (e.status === 400) { logTimeForServerTrace(); retryWithBareParams(); } else throw e; }","preventionTips":["Whitelist sort_by/sort_dir values on the client before sending","Clamp pagination to sane ranges","If a bare list call fails, suspect DB health, not parameters"],"tags":["chats","http-400","catch-all","pagination","database"],"backgroundTag":null,"analyzedSha":"01f4282f1ffe0d6212f58d3afbeae21fffd0c4be","analyzedAt":"2026-08-14T18:25:22.715Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}