odysseus-dev/odysseus · warning · HTTPException
Album name required
Error message
Album name required
What it means
HTTP 400 raised by POST /api/gallery/albums when the album name is empty after trimming. The handler strips data['name'] and rejects blank, missing, or null values before creating the GalleryAlbum row.
Source
Thrown at routes/gallery/gallery_routes.py:857
if first:
cover_url = f"/api/generated-image/{first.filename}"
result.append({
"id": a.id, "name": a.name, "description": a.description or "",
"cover_url": cover_url, "count": count,
"created_at": a.created_at.isoformat() if a.created_at else None,
})
return {"albums": result}
finally:
db.close()
@router.post("/api/gallery/albums")
async def create_album(request: Request):
import uuid
user = get_current_user(request)
data = await request.json()
name = (data.get("name") or "").strip()
if not name:
raise HTTPException(400, "Album name required")
db = SessionLocal()
try:
a = GalleryAlbum(
id=str(uuid.uuid4()), name=name,
description=data.get("description", ""),
owner=user,
)
db.add(a)
db.commit()
return {"ok": True, "id": a.id, "name": a.name}
finally:
db.close()
@router.get("/api/gallery/stats")
async def gallery_stats(request: Request):
user = get_current_user(request)
db = SessionLocal()
try:View on GitHub (pinned to f9235ebbf1)
Solutions
- Require non-blank input in the album-creation form.
- Send the key as exactly "name".
- Trim client-side and skip the request when empty.
Example fix
// before
await post('/api/gallery/albums', {title: v}); // wrong key -> 400
// after
const name = v.trim(); if (!name) return;
await post('/api/gallery/albums', {name, description: ''}); Defensive patterns
Strategy: validation
Validate before calling
const name = (input?.value ?? '').trim();
if (!name) return showError('Album name is required');
await post('/api/gallery/albums', {name}); Type guard
const isNonBlankAlbumName = (v) => typeof v === 'string' && v.trim().length > 0;
Prevention
- Use the exact key 'name'
- Require the field in the create-album form
- Trim input client-side
When it happens
Trigger: POST /api/gallery/albums with {}, {"name": ""}, {"name": " "}, or {"name": null}.
Common situations: Creating an album from an empty dialog; frontend sending 'title' instead of 'name'; double submits clearing the field.
Related errors
AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14).
Data as JSON: /api/errors/8596a1ba15ec3f60.
Report an issue: GitHub.