Repository navigation
Fix: dashboard overview crashes when an agent has no recorded cost - #31
Merged
Merged
Conversation
Since cost_summary() stopped collapsing unknown cost to $0 (PR secfoo-com#30), an agent whose runs are all unpriced (devin, droid, cursor, agy) comes back with cost_usd=None. The overview page added every agent's cost with a plain sum(), so one priced run plus one unpriced agent raised TypeError and "/" returned 500. Use sum_optional(), as the `secfoo cost` Total row already does. The "AI spend by agent" table had the same problem with tokens: a run can have a cost but no token counts, and the template added None + None. Show "-" when no token count is known. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 tasks done
Collaborator
|
Could a maintainer review this when you get a chance? On #34 (SECFOO-69 UI improvements) depends on this fix for the dashboard, so it would help to merge this one first. Thanks! |
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.
What does this change, and why?
Found during the SECFOO-12 dashboard check: after PR #30, the dashboard
home page (
/) returns 500 for anyone who has run a priced agent(e.g. claude) and an agent that doesn't report cost (devin, droid,
cursor, agy).
PR #30 correctly made
cost_summary()returncost_usd=Nonefor anall-unpriced group instead of
0, but the overview page still summedwith plain
sum(). This switches it tosum_optional(), which thesecfoo costCLI Total row already uses. Same result as before whennothing is priced (
None→ "-").Fixing that exposed a second crash in the same "AI spend by agent"
table:
overview.htmladdedinput_tokens + output_tokensfor anypriced row, but a run can have a cost with no token counts (my local
store has one), giving
None + None. It now shows "-" when no tokencount is known.
Testing
pytest testspasses (813 passed)ruff checkpasses on the changed source filetest_overview_totals_cost_when_one_agent_is_unpriced(fails on main with the TypeError above, passes with this fix)
~/.secfoostore:/went from 500 to 200