Skip to content

[19.0][FIX] fs_attachment: stream without mimetype - #693

Open
djchavex wants to merge 1 commit into
OCA:19.0from
djchavex:19.0-fix-fs_attachment-stream-no-mimetype
Open

djchavex wants to merge 1 commit into
OCA:19.0from
djchavex:19.0-fix-fs_attachment-stream-no-mimetype

Conversation

@djchavex

@djchavex djchavex commented Nov 7, 2026

Copy link
Copy Markdown

An attachment stored in an fs.storage whose mimetype is empty is served as
False, and two places crash on it:

Core fills the empty mimetype for data/path streams with default_mimetype
(guess_mimetype(head, default=default_mimetype)); this does the same for fs
streams. The extension guess moves inside the fs branch, since it only
applies to those streams.

The mimetype can be empty for attachments written outside the ORM: imports,
migrations, or code writing the column directly. GET /web/content/<id> on
such an attachment returned a 500.

Verification on 19.0:

  • with the fix: TestStream — 0 failed, 0 error(s) of 9 tests;
  • without the model change (tests only): test_content_url_without_mimetype
    errors with AttributeError: 'bool' object has no attribute 'lower', so the
    regression test does catch it.

Forward-port of #685 to 19.0 — same change, same tests, plus the newsfragment.

Fixes #684

An attachment stored in an `fs.storage` whose `mimetype` is empty is
served as `False`, and two places crash on it: `guess_extension()` in
`_get_stream_from` and werkzeug's `send_file` in `FsStream.get_response`,
both with `AttributeError: 'bool' object has no attribute ...`.

Core fills the empty mimetype for `data`/`path` streams with
`default_mimetype`; do the same for `fs` streams. The extension guess
moves inside the `fs` branch, since it only applies to those streams.

The mimetype can be empty for attachments written outside the ORM:
imports, migrations, or code writing the column directly.

Forward-port of OCA#685 to 19.0.
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @lmignon,
some modules you are maintaining are being modified, check this out!

@lmignon lmignon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Authorship is not preserved. When a PR is forward ported,the commit history must be preserved. The oca-port can assist you in this process

@polcerverapyming polcerverapyming left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Odoo 19.0. An fs attachment with an empty mimetype no longer crashes: _get_stream_from falls back to the default mimetype and /web/content/ returns 200 instead of 500, while extension guessing for fs streams still works. Works as expected. LGTM

@lmignon

lmignon commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Tested on Odoo 19.0. An fs attachment with an empty mimetype no longer crashes: _get_stream_from falls back to the default mimetype and /web/content/ returns 200 instead of 500, while extension guessing for fs streams still works. Works as expected. LGTM

@polcerverapyming It can't be merged since the authorship is not preserved into the forward port process of the original PR...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[18.0][19.0] fs_attachment: 500 when downloading an fs attachment without mimetype

4 participants