feat: add image attachments to messages
- upload, metadata and download endpoints for PNG/JPEG attachments:
limits before reading and decompression, type by content,
structural integrity check without decoding pixels, safe filename
- write order: pending row with object key -> PUT to S3 -> ready;
per-step DB sessions so no pool connection is held during transfers
- attachment_ids in messages (validation, idempotency hash, history);
whitespace-only text allowed with an attachment (teacher, 2026-10-20)
- migration: attachments and message_attachments tables, text length
CHECK relaxed with NOT VALID
- student tests, fault checks and driver commands for attachments;
rollout profile starts from e1161f7 and checks the commit first
- sync attachments deltas into main specs; rules, AGENTS.md, PLAN.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,8 +28,17 @@ DOMAIN_ERRORS: dict[type[exceptions.DomainError], tuple[int, ErrorCode]] = {
|
||||
exceptions.UsernameTaken: (409, ErrorCode.CONFLICT),
|
||||
exceptions.IdempotencyConflict: (409, ErrorCode.CONFLICT),
|
||||
exceptions.ChatNotFound: (404, ErrorCode.NOT_FOUND),
|
||||
exceptions.AttachmentNotFound: (404, ErrorCode.NOT_FOUND),
|
||||
exceptions.InvalidChatMembers: (400, ErrorCode.INVALID_REQUEST),
|
||||
exceptions.InvalidCursor: (400, ErrorCode.INVALID_REQUEST),
|
||||
exceptions.UploadInterrupted: (400, ErrorCode.INVALID_REQUEST),
|
||||
exceptions.PayloadTooLarge: (413, ErrorCode.PAYLOAD_TOO_LARGE),
|
||||
exceptions.UnsupportedMediaType: (
|
||||
415,
|
||||
ErrorCode.UNSUPPORTED_MEDIA_TYPE,
|
||||
),
|
||||
# расхождение БД и S3, а не ошибка клиента: причина — в журнале
|
||||
exceptions.AttachmentContentMissing: (500, ErrorCode.INTERNAL_ERROR),
|
||||
exceptions.ServiceUnavailable: (503, ErrorCode.UNAVAILABLE),
|
||||
# доменная ошибка без своей строки — некорректный запрос
|
||||
exceptions.DomainError: (400, ErrorCode.INVALID_REQUEST),
|
||||
|
||||
Reference in New Issue
Block a user