Repository navigation
Y25-467 - Handle invalid byte sequence exception - #6098
Open
StephenHulme wants to merge 9 commits into
Open
StephenHulme wants to merge 9 commits into
StephenHulme wants to merge 9 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6098 +/- ##
===========================================
+ Coverage 82.22% 82.24% +0.01%
===========================================
Files 1317 1317
Lines 32208 32210 +2
Branches 3503 3503
===========================================
+ Hits 26482 26490 +8
+ Misses 4920 4912 -8
- Partials 806 808 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
StephenHulme
commented
Oct 6, 2026
Comment on lines
+129
to
150
| context 'when the upload fails due to an Invalid byte sequence error' do | ||
| before do | ||
| allow(uploader).to receive(:run!).and_raise(CSV::InvalidEncodingError.new(Encoding::UTF_8, 10)) | ||
| allow(Rails.logger).to receive(:error).and_call_original | ||
| post :create, params: { upload: upload_file } | ||
| end | ||
|
|
||
| it 'logs the invalid encoding error' do | ||
| expect(Rails.logger).to have_received(:error).with('Invalid byte sequence in UTF-8 in line 10.') | ||
| end | ||
|
|
||
| it 'sets an error flash message' do | ||
| expect(flash[:error]).to eq( | ||
| 'The sample manifest contained invalid encoding and could not be uploaded: ' \ | ||
| 'Invalid byte sequence in UTF-8 in line 10.' | ||
| ) | ||
| end | ||
|
|
||
| it 'renders the new template' do | ||
| expect(response).to render_template(:new) | ||
| end | ||
| end |
Member
Author
There was a problem hiding this comment.
The added unit test 👆
This branch has not been deployed
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.
Closes #5122
Changes proposed in this pull request
CSV::InvalidEncodingErrorI could not replicate the same failure mode as in the exception notifications, but have added the suggested error handling which should catch any future occurrences.
Instructions for Reviewers
[All PRs] - Confirm PR template filled
[Feature Branches] - Review code
[Production Merges to
main]- Check story numbers included
- Check for debug code
- Check version