fix(reports): normalize output paths with wrong extensions#209
Conversation
Align MarkdownReport, JSONReport, and ComparisonReport with the HTMLReport/TerminalReport pattern: treat extensionless paths as directories and replace mismatched suffixes via with_suffix(). Fixes OpenAgentHQ#84
|
/oc review pr in details |
|
Review summary — strongly positive, approve. Bug analysisThe old code in all three generators used # Before (broken)
path = Path(output_path)
if not str(path).endswith(".md"): # e.g. "results.txt" → False
path = path / "report.md" # → "results.txt/report.md" ☠️When given What the fix doesReplaces # After (fixed)
path = Path(output_path)
if path.suffix == "": # no ext → directory
path = path / "report.md"
elif path.suffix.lower() != ".md": # wrong ext → normalize
path = path.with_suffix(".md")Per-file changes
TestsEach test file adds a regression test: Minor observations
Overall: Correct, minimal, consistent with existing patterns, well-tested. |
|
🎉 Congratulations @syf2211! Your pull request has been successfully merged into main. 🚀 Thank you for contributing to OpenAgentHQ and helping improve the project. We truly appreciate your contribution and hope to see you back with more amazing PRs! Happy Open Sourcing! ❤️ |

Summary
Fix
generate_to_file()in MarkdownReport, JSONReport, and ComparisonReport so paths with a non-matching extension (e.g.results.txt) are normalized viawith_suffix()instead of creating nested directory paths likeresults.txt/report.md.Motivation
Fixes #84. HTMLReport and TerminalReport already used the correct
path.suffix/with_suffix()pattern; the other three report generators still relied onendswith(), which misclassified wrong-extension paths as directories.Changes
openagent_eval/reports/markdown.py: normalize.mdoutput pathsopenagent_eval/reports/json_report.py: normalize.jsonoutput pathsopenagent_eval/reports/comparison.py: normalize.txtoutput paths and align call order with other generatorstests/unit/test_reports/test_markdown.py,test_json_report.py, andtest_comparison.pyTests
Result: 44 passed
Notes
.MD→.md) matches the existing HTMLReport/TerminalReport behavior.