{"record":{"id":"b59bcf47ed357273","repo":"Significant-Gravitas/AutoGPT","slug":"title-must-not-be-blank","errorCode":null,"errorMessage":"Title must not be blank","messagePattern":"Title must not be blank","errorType":"validation","errorClass":"ValueError","httpStatus":422,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/chat/routes.py","lineNumber":404,"sourceCode":"\nclass CancelSessionResponse(BaseModel):\n    \"\"\"Response model for the cancel session endpoint.\"\"\"\n\n    cancelled: bool\n    reason: str | None = None\n\n\nclass UpdateSessionTitleRequest(BaseModel):\n    \"\"\"Request model for updating a session's title.\"\"\"\n\n    title: str\n\n    @field_validator(\"title\")\n    @classmethod\n    def title_must_not_be_blank(cls, v: str) -> str:\n        stripped = v.strip()\n        if not stripped:\n            raise ValueError(\"Title must not be blank\")\n        return stripped\n\n\nclass UpdateSessionPinnedRequest(BaseModel):\n    \"\"\"Request model for pinning/unpinning a session.\"\"\"\n\n    is_pinned: bool\n\n\n# ========== Routes ==========\n\n\n@router.get(\n    \"/sessions\",\n    dependencies=[Security(auth.requires_user)],\n)\nasync def list_sessions(\n    user_id: Annotated[str, Security(auth.get_user_id)],","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/chat/routes.py#L386-L422","documentation":"A Pydantic ValidationError (HTTP 422) from the UpdateSessionTitleRequest model: the title field's title_must_not_be_blank validator strips the value and rejects any input that is empty or whitespace-only. The validator also normalizes: the returned value is the stripped title, so leading/trailing spaces never reach storage.","triggerScenarios":"PATCH /chat/sessions/{session_id}/title with body {\"title\": \"\"}, {\"title\": \"   \"}, or {\"title\": \"\\t\\n\"}; also a client sending a title built from an unvalidated empty input field.","commonSituations":"Frontend form submitted without a required check on the title input; a 'rename' UI that allows saving with the textbox cleared; programmatic rename passing an untrimmed variable that is all whitespace.","solutions":["Validate client-side before the request: trim the title and require length >= 1.","In the rename UI, disable the save button when the trimmed input is empty.","Expect the stored title to be stripped — do not attempt to preserve leading/trailing whitespace through this endpoint."],"exampleFix":"// before\nawait fetch(`/chat/sessions/${id}/title`, {method: 'PATCH', body: JSON.stringify({title: rawInput})})\n\n// after\nconst title = rawInput.trim();\nif (title) await fetch(`/chat/sessions/${id}/title`, {method: 'PATCH', body: JSON.stringify({title})})","handlingStrategy":"validation","validationCode":"const title = rawTitle.trim();\nif (!title) return; // don't PATCH\nawait updateTitle(sessionId, title);","typeGuard":"function isValidTitle(t: string): boolean {\n  return t.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Trim inputs before submit; disable save on empty.","Remember the backend stores the stripped title."],"tags":["backend","chat","validation","pydantic","http-422"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}