feat: Hard-limit original image byte size to 2 * max_bytes if recoding fails (#8296)#8300
Open
iequidoo wants to merge 1 commit into
Open
feat: Hard-limit original image byte size to 2 * max_bytes if recoding fails (#8296)#8300iequidoo wants to merge 1 commit into
2 * max_bytes if recoding fails (#8296)#8300iequidoo wants to merge 1 commit into
Conversation
…ing fails (#8296) `max_bytes` isn't a strict limit for non-avatars (note: it's 500 kB by default), still, we don't want to send a gigabyte if recoding fails. Also add a comment why we downgrade to `Viewtype::File` if the image couldn't be decoded.
c081082 to
f2a315e
Compare
iequidoo
commented
Jun 3, 2026
| context, | ||
| "Cannot check/recode image, using original data: {err:#}.", | ||
| ); | ||
| // NB: If the image can't be decoded, but the user had chosen `Viewtype::File` |
Collaborator
Author
There was a problem hiding this comment.
Maybe this should be documented even at the API level because this isn't just an implementation detail, but an observable behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
max_bytesisn't a strict limit for non-avatars (note: it's 500 kB by default), still, we don't want to send a gigabyte if recoding fails.Also add a comment why we downgrade to
Viewtype::Fileif the image couldn't be decoded.This PR is to have a separate discussion because the current code looks to have this point missed. I remember there were discussions that we don't have any hard limit because the user may send an image and optimistically switch to another chat or even app expecting that the image will be sent somehow, but i think that if the user really cares, they should check the result, otherwise there may even be no network etc. But i'm not a UX expert. Anyway, the reasoning should be documented and some test added, even if we don't want to change the code. CC @r10s
Related to: #8296