Repository navigation
tests: stop crash-log assertions failing on non-UTF-8 log bytes - #10910
Merged
Merged
Conversation
A crash report, and the log lines interleaved with it while the crash
handler runs, can contain raw memory bytes. `test_crash` and
`test_tracing` read the server log with the default strict UTF-8 decode,
so a single invalid byte anywhere in the file raises UnicodeDecodeError
and errors the test out before it can check anything:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position
3286: invalid start byte
Both only match ASCII fragments, so decode lossily and pin the encoding
rather than inheriting it from the locale.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
GuyAv46
approved these changes
Aug 13, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10910 +/- ##
==========================================
- Coverage 83.19% 82.21% -0.98%
==========================================
Files 608 632 +24
Lines 81025 82134 +1109
Branches 36273 37382 +1109
==========================================
+ Hits 67405 67529 +124
- Misses 13274 14259 +985
Partials 346 346
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:
|
|
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.



Describe the changes in the pull request
Current:
test_crash.pyandtest_tracing.pyread the server log file withopen(path)— the default strict UTF-8 decode. A crash report, and any log lineinterleaved with it while the crash handler runs, can contain raw memory bytes, so
the log is not guaranteed to be valid UTF-8. A single invalid byte anywhere in the
file aborts the read, and the test errors out before it can assert anything:
This was hit in CI by
test_crash:test_query_thread_crash, where a background threadlogged the raw bytes of a pointer while the crash handler was running its memory test:
The failure has nothing to do with the fragments the test is looking for — those were
all present and correct in that same log.
Change: read the log with
encoding="utf-8", errors="replace"at both call sites.Both only match ASCII fragments, so a lossy decode cannot change what they find.
Pinning the encoding also stops the decode depending on the runner's locale.
Outcome: the crash tests assert on the crash report's contents instead of failing
on unrelated bytes elsewhere in the log. Replaying
extract_query_crash_output'sparser over the log that failed in CI now finds all eight expected fragments in order
and satisfies every assertion in
test_query_thread_crash(
search_number_of_docs: 10,max_doc_id=10,num_terms=2,inverted_size > 0).Which additional issues this PR fixes
Main objects this PR modified
tests/pytests/test_crash.py—extract_query_crash_output()tests/pytests/test_tracing.py—_log_has_init_message()Mark if applicable
Release Notes