[1.4.x] Read report/label templates in binary mode (#12432) - #12441
Merged
Conversation
* Read report/label templates in binary mode file_from_template read the template in text mode and wrapped the string in a ContentFile. The ContentFile size then reflected the character count, which differs from the UTF-8 byte length for any template that contains multi-byte characters. Strict S3 implementations such as Backblaze B2 validate the Content-Length header and reject the upload with an IncompleteBody error. AWS S3 tolerates the mismatch, so the problem is not visible there. inventree_transfer_order_report.html is 1458 characters but 1460 bytes. Its upload fails during create_default_reports, the transaction rolls back, and the default template is recreated and fails again on every startup. Use Path.read_bytes() so the ContentFile size matches the uploaded bytes and the file handle is closed. Add a regression test asserting the size equals the file's byte length. * Test file_from_template across text encodings (cherry picked from commit ce47cda)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.4.x #12441 +/- ##
==========================================
+ Coverage 86.70% 86.72% +0.01%
==========================================
Files 1389 1389
Lines 90477 90621 +144
Branches 10222 10222
==========================================
+ Hits 78452 78590 +138
- Misses 11964 11970 +6
Partials 61 61
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Backport
This will backport the following commits from
masterto1.4.x:Questions ?
Please refer to the Backport tool documentation