Skip to content

Fix failure file dump when output has invalid UTF8#365

Merged
ChrisBr merged 1 commit into
Shopify:mainfrom
skipkayhil:hm-muozxolwvrrwqyzr
Dec 10, 2025
Merged

Fix failure file dump when output has invalid UTF8#365
ChrisBr merged 1 commit into
Shopify:mainfrom
skipkayhil:hm-muozxolwvrrwqyzr

Conversation

@skipkayhil

Copy link
Copy Markdown
Contributor

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.

@ChrisBr ChrisBr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks!

@ChrisBr

ChrisBr commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

Are the failed tests for 2.7 related?

Minitest::UnexpectedError:         FrozenError: can't modify frozen String: "\e[31mFAIL\e[0m Minitest::Test#a\n\e[33mSomething went wrong\e[0m\n    test/support/reporter_test_helper.rb:15:in `runnable'\n    test/support/reporter_test_helper.rb:6:in `result'\n    test/minitest/reporters/junit_reporter_test.rb:65:in `test_generate_junitxml_for_errored_test'\n\n"

@hmcguire-shopify

Copy link
Copy Markdown

Are the failed tests for 2.7 related?

Minitest::UnexpectedError:         FrozenError: can't modify frozen String: "\e[31mFAIL\e[0m Minitest::Test#a\n\e[33mSomething went wrong\e[0m\n    test/support/reporter_test_helper.rb:15:in `runnable'\n    test/support/reporter_test_helper.rb:6:in `result'\n    test/minitest/reporters/junit_reporter_test.rb:65:in `test_generate_junitxml_for_errored_test'\n\n"

Oh, whoops I didn't see those with all the python failures 😅 I'll get those fixed

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.
@hmcguire-shopify

Copy link
Copy Markdown

Okay, should be good now 🟢

TIL encode! works on frozen strings only in Ruby 3.0+

@ChrisBr
ChrisBr merged commit 785a342 into Shopify:main Dec 10, 2025
8 of 13 checks passed
@ChrisBr

ChrisBr commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

Thanks for fixing!

@skipkayhil
skipkayhil deleted the hm-muozxolwvrrwqyzr branch December 10, 2025 18:35
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.

3 participants