Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions misc/scripts/accept-expected-changes-from-ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,37 @@ def make_patches_from_log_file(log_file_lines) -> List[Patch]:
line = parse_log_line(raw_line)

if line == "--- expected":
while True:
next_line = parse_log_line(next(lines))
if next_line == "+++ actual":
break
try:
while True:
next_line = parse_log_line(next(lines))
if next_line == "+++ actual":
break

lines_changed = []
lines_changed = []

while True:
next_line = parse_log_line(next(lines))
# it can be the case that
if next_line and next_line[0] in (" ", "-", "+", "@"):
lines_changed.append(next_line)
if "FAILED" in next_line:
break
while True:
next_line = parse_log_line(next(lines))
# it can be the case that
if next_line and next_line[0] in (" ", "-", "+", "@"):
lines_changed.append(next_line)
if "FAILED" in next_line:
break

# error line _should_ be next, but sometimes the output gets interleaved...
# so we just skip until we find the error line
error_line = next_line
while True:
# internal
filename_match = re.fullmatch(r"^##\[error\].*FAILED\(RESULT\) (.*)$", error_line)
if not filename_match:
# codeql action
filename_match = re.fullmatch(r"^.*FAILED\(RESULT\) (.*)$", error_line)
if filename_match:
break
error_line = parse_log_line(next(lines))
# error line _should_ be next, but sometimes the output gets interleaved...
# so we just skip until we find the error line
error_line = next_line
while True:
# internal
filename_match = re.fullmatch(r"^##\[error\].*FAILED\(RESULT\) (.*)$", error_line)
if not filename_match:
# codeql action
filename_match = re.fullmatch(r"^.*FAILED\(RESULT\) (.*)$", error_line)
if filename_match:
break
error_line = parse_log_line(next(lines))
except StopIteration:
LOGGER.warning("Encountered unexpected end of logs while parsing failure block.")
break
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The variable filename_match may be undefined when accessed at this line. If StopIteration is caught at line 134, the code breaks out of the try block, but filename_match will not have been assigned if the exception occurred before line 127 or if no match was found before the exception. This will cause an UnboundLocalError. The continue statement should be used instead of break in the exception handler to skip to the next iteration of the outer for loop.

Suggested change
break
continue

Copilot uses AI. Check for mistakes.

full_path = filename_match.group(1)

Expand Down
Loading