Skip to content

fix(genReport): prevent KeyError when no .log files by initializing last_log#4068

Merged
maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
ashnaaseth2325-oss:fix/genreport-last-log-keyerror
Mar 28, 2026
Merged

fix(genReport): prevent KeyError when no .log files by initializing last_log#4068
maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
ashnaaseth2325-oss:fix/genreport-last-log-keyerror

Conversation

@ashnaaseth2325-oss

@ashnaaseth2325-oss ashnaaseth2325-oss commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

1. SUMMARY

This PR fixes a crash in genReport.py caused by accessing an uninitialized last_log key when no .log files are present. It ensures safe initialization and consistent behavior with existing fields.


2. FIX

# Before
d["log_errors"] = list()
d["log_warnings"] = list()
for name_ in sorted(files):
    if name_.endswith(".log"):
        d["last_log"] = name_
d["finished"] = d["last_log"] in LAST_EXPECTED_LOG

# After
d["log_errors"] = list()
d["log_warnings"] = list()
d["last_log"] = ""
for name_ in sorted(files):
    if name_.endswith(".log"):
        d["last_log"] = name_
d["finished"] = d["last_log"] in LAST_EXPECTED_LOG

3. VERIFICATION

Tested by running genReport.py on a log directory with no .log files and with only non-log files present. The script no longer crashes and completes execution without any traceback. The report is generated correctly with finished=False, confirming graceful handling of missing logs.

Initialize d["last_log"] = "" before the os.walk loop so that
designs with no .log files report finished=False instead of crashing.

Signed-off-by: Ashnaa Seth <ashnaaseth2325@gmail.com>
Signed-off-by: ashnaaseth2325-oss <ashnaaseth2325@gmail.com>
@ashnaaseth2325-oss

Copy link
Copy Markdown
Contributor Author

Hi @maliberty @eder-matheus,
Kindly review this PR.
Thanks!

@maliberty maliberty enabled auto-merge March 28, 2026 15:09
@maliberty maliberty merged commit 0a94308 into The-OpenROAD-Project:master Mar 28, 2026
8 of 9 checks passed
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