Skip to content

[16.0] [FIX] fs_attachment: prevent 416 on Range requests with X-Accel-Redirect#586

Closed
giarve wants to merge 1 commit intoOCA:16.0from
wvbs:16.0
Closed

[16.0] [FIX] fs_attachment: prevent 416 on Range requests with X-Accel-Redirect#586
giarve wants to merge 1 commit intoOCA:16.0from
wvbs:16.0

Conversation

@giarve
Copy link
Copy Markdown

@giarve giarve commented Apr 2, 2026

Currently range requests are not working (for example in preview videos in Discuss application using firefox) early terminated with HTTP error 416

Media resource baseurl/mail/channel/340/attachment/56318 could not be decoded, error: Error Code: NS_ERROR_DOM_MEDIA_RANGE_ERR (0x806e0069)
Details: Result<already_AddRefed, MediaResult> __cdecl mozilla::SampleIterator::GetNext(void): Sample data read failed

Why fs_attachment and not fs_attachment_s3?

_fs_use_x_sendfile() checks fs_storage_id.use_x_sendfile_to_serve_internal_url — this is a generic flag on any fs.storage record, not S3-specific. The _send_file("") bug triggers for every backend (S3, local filesystem, SFTP, whatever) that has this checkbox enabled.

The flow is:

FsStream.get_response() in fs_attachment calls _send_file("") -> bug is here
fs_attachment_s3 only extends how the redirect URL is built, not the response creation
So fs_attachment is the correct place. Moving it to fs_attachment_s3 would leave the bug open for any other storage using X-Accel-Redirect.

_send_file("") stats the current working directory, giving werkzeug a
complete_length of 4096 (Linux dir block size). When the browser sends
a Range header for video streaming, werkzeug rejects it with 416
because the requested byte offset exceeds 4096.

Strip HTTP_RANGE from the environ passed to werkzeug so it skips Range
validation. S3/nginx handle Range requests natively through the
X-Accel-Redirect path.
@OCA-git-bot
Copy link
Copy Markdown
Contributor

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

@giarve giarve closed this Apr 6, 2026
@giarve
Copy link
Copy Markdown
Author

giarve commented Apr 6, 2026

not sure yet if this is due to network issues or large files

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants