You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Attachment uploads don't record the content type #48
`INSERT INTO msg_attachment (msg_id, filename, filesize, filepath)
VALUES ($1, $2, $3, $4)
ON CONFLICT (msg_id, filename) DO UPDATE SET filesize=$3, filepath=$4`,
msgID, intendedFilename, written, finalPath,
So every uploaded attachment keeps the schema default, application/octet-stream. That's the type that goes on the wire in the fmsg message and the one returned by the message and thread endpoints. Meanwhile, GET /fmsg/:id/attach/:filename serves the file with a type inferred from its extension. Clients see the same attachment with two different types, depending on which endpoint they ask.
Reported by an MCP client that sent spark.png with image/png:
the thread view listed it as application/octet-stream;
the download returned image/png.
Suggested fix
Store a content type on upload. Use the multipart part's Content-Type when it's a valid, specific media type, otherwise infer one from the filename extension (mime.TypeByExtension). Fall back to application/octet-stream only when neither gives a type.
Persist it in msg_attachment.type (insert, and the ON CONFLICT update).
Optionally, validate the result with mime.ParseMediaType.
Existing rows keep application/octet-stream. Clients can keep inferring from the extension for those.
Activity