[Shopify Sync] Fix failure dump with invalid UTF-8#89
Merged
dkeegan-figma merged 1 commit intomasterfrom Dec 16, 2025
Merged
Conversation
Previously, any invalid UTF-8 in test output would prevent the entire JSON failure file from being dumped, because the Ruby JSON library validates that its output is UTF-8. This commit aims to fix this issue by encoding the output as UTF-8 before it gets to JSON so that the file can always be dumped.
lihao-figma
approved these changes
Dec 12, 2025
ebarajas
approved these changes
Dec 16, 2025
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.
Summary
Cherry-picks Shopify's UTF-8 encoding fix (commit
ed4ae26). Prevents JSON dump failures when test output contains invalid UTF-8 bytes, ensuring failure reports are always written successfully.Changes
Modified Files
ruby/lib/minitest/queue/failure_formatter.rb- Added UTF-8 encoding with replacementNew Files
ruby/test/minitest/queue/failure_formatter_test.rb- Test for UTF-8 handlingThe Bug
When test output contains invalid UTF-8 bytes (e.g., from binary data, malformed strings), the Ruby JSON library raises an exception because it validates UTF-8 encoding:
This prevents the entire failure report from being written, losing valuable debugging information.
The Fix
Encode output as UTF-8 before JSON serialization, replacing invalid bytes with empty string:
Example
Conflict Resolution
✅ Applied cleanly - No conflicts!
Benefits
Real-World Scenarios
This fixes failures when tests interact with:
Testing
Original Shopify PR
ed4ae26Risk Assessment
Risk Level: Very Low
Additional Notes
The fix uses
replace: ''(empty string) to remove invalid bytes. Alternative would bereplace: '?'to show where bytes were replaced, but empty string is cleaner for most use cases.cc: @Dkeegan