Skip to content

fix(logfiles): handle CRLF chunk splits and glob metacharacters - #3583

Merged
mkoura merged 1 commit into
masterfrom
logfiles_edge_cases
Aug 3, 2026
Merged

fix(logfiles): handle CRLF chunk splits and glob metacharacters#3583
mkoura merged 1 commit into
masterfrom
logfiles_edge_cases

Conversation

@mkoura

@mkoura mkoura commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

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.

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.
@mkoura
mkoura requested a review from saratomaz as a code owner August 3, 2026 15:36
@mkoura
mkoura requested review from Copilot and removed request for saratomaz August 3, 2026 15:36

Copilot AI 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.

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 \r at 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_dir path 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.

@mkoura
mkoura merged commit 1f6254d into master Aug 3, 2026
4 checks passed
@mkoura
mkoura deleted the logfiles_edge_cases branch August 3, 2026 15:55
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.

2 participants