fix(skill-creator): don't crash report generator on empty history#427
Open
mvanhorn wants to merge 1 commit into
Open
fix(skill-creator): don't crash report generator on empty history#427mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
generate_html() called max(history, ...) unconditionally, so rendering a report before the first iteration completes (empty history) raised ValueError: max() iterable argument is empty. Guard the empty case with best_iter = None; the highlight is only consumed by the per-iteration row loop, which does not run when history is empty. Closes OpenBMB#417
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generate_html()inskills/skill-creator/scripts/generate_report.pycallsmax(history, ...)unconditionally to pick the best iteration to highlight. Whenhistoryis empty,max()raisesValueError: max() iterable argument is empty, so the report generator crashes instead of producing a valid report.Closes #417.
Why this matters
The report is meant to be rendered incrementally (the script even supports
auto_refresh), so it can legitimately be asked to render before the first iteration result exists — a live "run just started" state, a partial result, or any caller that wants a valid page before evaluation begins. Every other part ofgenerate_htmlalready tolerates an emptyhistory(the query-discovery block is guarded byif history:); the best-iteration highlight was the one spot that still assumed at least one iteration, turning an expected early state into a crash.Fix
Guard the empty case before the
max()calls:best_iteris only read inside thefor h in history:row loop, which does not run whenhistoryis empty, soNoneis safe. The non-empty path is unchanged.Testing
Reproduced against the current file:
generate_html({"history": []})raisedValueError: max() iterable argument is emptybefore the change and returns a valid ~5.8KB HTML document after it. A non-empty history still emits thebest-rowhighlight (verified), andpython3 -m py_compile generate_report.pypasses.