Skip to content

Handle missing log in export_report#33

Merged
Komzpa merged 1 commit into
masterfrom
codex/fix-keyerror--log--on-geocint
May 14, 2026
Merged

Handle missing log in export_report#33
Komzpa merged 1 commit into
masterfrom
codex/fix-keyerror--log--on-geocint

Conversation

@Komzpa
Copy link
Copy Markdown
Member

@Komzpa Komzpa commented Jun 13, 2025

Summary

  • avoid KeyError: 'log' by defaulting to an empty string when a target has no log

Testing

  • pytest -q

https://chatgpt.com/codex/tasks/task_e_684c5808d7dc8324a83c94b0920f17e8

Summary by CodeRabbit

  • Bug Fixes

    • Exported reports now always include the log reference as a string (empty when the original value is missing), preventing null/undefined entries in report output.
  • Tests

    • Added an automated test to validate that exported reports normalize missing log values to an empty string.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 13, 2025

Warning

Rate limit exceeded

@Komzpa has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 20 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ca857344-df97-436c-a34b-c07b6a567ea2

📥 Commits

Reviewing files that changed from the base of the PR and between d765373 and 81bce12.

📒 Files selected for processing (2)
  • make_profiler/report_export.py
  • tests/test_report_export.py

Walkthrough

Changed export_report to normalize falsy log values using rec.get("log") or "". Added a pytest ensuring that when a record's log is None, the exported status[0].targetLog is an empty string in report.json.

Changes

Report export normalization

Layer / File(s) Summary
Normalize log path computation and verification
make_profiler/report_export.py, tests/test_report_export.py
export_report now assigns log_path = rec.get("log") or "". A new test test_export_report_normalizes_missing_log_values writes a report with log=None and asserts status[0].targetLog == "".

Poem

In the warren where code lines hop,
A log check takes a shorter stop.
With .get it finds its way,
No more ifs to block the day.
Concise and neat, the rabbits cheer,
For simpler code is always dear! 🐇✨

Estimated code review effort:
🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: handling the missing log case in the export_report function to prevent KeyError.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-keyerror--log--on-geocint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
make_profiler/report_export.py (1)

75-83: 🧹 Nitpick (assertive)

Add a trailing comma to satisfy Ruff COM812.

The static-analysis hint flags the missing comma after the final dict entry. Adding it keeps diffs cleaner and stays compliant with the project’s style/lint rules.

                  "lastTargetCompletionTime": last_event_time,
-                 "targetLog": log_path
+                 "targetLog": log_path,
🧰 Tools
🪛 Ruff (0.11.9)

82-82: Trailing comma missing

Add trailing comma

(COM812)


83-83: Trailing comma missing

Add trailing comma

(COM812)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 65b4a94 and 655b9c2.

📒 Files selected for processing (1)
  • make_profiler/report_export.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
make_profiler/report_export.py

82-82: Trailing comma missing

Add trailing comma

(COM812)

Comment thread make_profiler/report_export.py Outdated
@Komzpa Komzpa force-pushed the codex/fix-keyerror--log--on-geocint branch from 655b9c2 to d765373 Compare May 13, 2026 23:35
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
make_profiler/report_export.py (1)

9-9: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add docstring to export_report function.

The function lacks a docstring describing its purpose, parameters, and behavior. As per coding guidelines, Python functions should have docstrings for call graph generation and documentation.

📝 Suggested docstring
 def export_report(performance, docs, targets):
+    """
+    Export build performance data to report.json.
+    
+    Args:
+        performance: Dict mapping target names to performance records
+        docs: Dict mapping target names to descriptions
+        targets: Set of valid target names from makefile
+    """
     strOutputFile = 'report.json'

As per coding guidelines, "Write docstrings in Python code, they will get used for call graph and generated documentation."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@make_profiler/report_export.py` at line 9, Add a descriptive triple-quoted
docstring to the export_report function that explains its purpose (what kind of
report it exports), lists and describes the parameters performance, docs, and
targets (expected types/structures and how they are used), documents the return
value (or None) and any side effects (file writes, network calls, raising
exceptions), and optionally provides a short example or notes on behavior; place
the docstring immediately inside the export_report function definition so it is
picked up by tooling and call-graph generation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_report_export.py`:
- Around line 6-29: Add a new test mirroring
test_export_report_normalizes_missing_log_values to cover the case where the
performance record omits the "log" key: create
test_export_report_handles_missing_log_key that calls
report_export.export_report with the same build dict but without any "log" key,
ensure you call monkeypatch.chdir(tmp_path) and clear report_export.status and
report_export.status_list before invoking export_report, read
tmp_path/"report.json" and assert report["status"][0]["targetLog"] == "" to
verify the exporter produces an empty string when "log" is missing.

---

Outside diff comments:
In `@make_profiler/report_export.py`:
- Line 9: Add a descriptive triple-quoted docstring to the export_report
function that explains its purpose (what kind of report it exports), lists and
describes the parameters performance, docs, and targets (expected
types/structures and how they are used), documents the return value (or None)
and any side effects (file writes, network calls, raising exceptions), and
optionally provides a short example or notes on behavior; place the docstring
immediately inside the export_report function definition so it is picked up by
tooling and call-graph generation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1d937dfa-e780-43ec-8659-7dcffb23d40f

📥 Commits

Reviewing files that changed from the base of the PR and between 655b9c2 and d765373.

📒 Files selected for processing (2)
  • make_profiler/report_export.py
  • tests/test_report_export.py

Comment thread tests/test_report_export.py Outdated
@Komzpa Komzpa force-pushed the codex/fix-keyerror--log--on-geocint branch from d765373 to 81bce12 Compare May 13, 2026 23:38
@Komzpa Komzpa merged commit 340da2b into master May 14, 2026
7 checks passed
@Komzpa Komzpa deleted the codex/fix-keyerror--log--on-geocint branch May 14, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant