fix(logfiles): handle CRLF chunk splits and glob metacharacters - #3583
Merged
Conversation
A "\r\n" line ending split across read chunk boundaries produced a spurious empty line - the trailing "\r" ended a line and the "\n" from the next chunk became an empty line. The empty lines consumed look-back window slots, so a trigger message could be evicted early and a mapped error wrongly reported. Treat a trailing "\r" of a chunk as an incomplete line - the next chunk or the end-of-file handling completes it. Glob metacharacters in a log file name (e.g. "node[1].stdout") made the file invisible to its own rotation glob, so the file was silently not searched. Metacharacters in the state dir path similarly broke the expected messages check. Escape the literal parts of the patterns.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the log-scanning utilities against two edge cases that could cause missed/incorrect log matching: CRLF sequences split across read chunk boundaries and glob metacharacters appearing in literal log filenames/paths. It updates the core line-splitting/search logic in cardano_node_tests/utils/logfiles.py and adds targeted unit tests in framework_tests/test_logfiles.py to prevent regressions.
Changes:
- Treat a trailing
\rat the end of a read chunk as an incomplete line tail (to correctly reassemble CRLF across chunk boundaries and avoid spurious empty lines). - Escape glob metacharacters in literal logfile names when collecting rotated logs.
- Escape glob metacharacters in the
state_dirpath when matching candidate logfiles for expected-message checks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| framework_tests/test_logfiles.py | Adds regression tests for CRLF chunk-boundary handling and for literal matching when filenames/paths contain glob metacharacters. |
| cardano_node_tests/utils/logfiles.py | Fixes line splitting across CRLF chunk boundaries and escapes literal path/name parts in glob-based matching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
A "\r\n" line ending split across read chunk boundaries produced a spurious empty line - the trailing "\r" ended a line and the "\n" from the next chunk became an empty line. The empty lines consumed look-back window slots, so a trigger message could be evicted early and a mapped error wrongly reported. Treat a trailing "\r" of a chunk as an incomplete line - the next chunk or the end-of-file handling completes it.
Glob metacharacters in a log file name (e.g. "node[1].stdout") made the file invisible to its own rotation glob, so the file was silently not searched. Metacharacters in the state dir path similarly broke the expected messages check. Escape the literal parts of the patterns.