fix: tolerate null allocation sets in allocation views - #292
Open
markusheiden wants to merge 1 commit into
Open
Conversation
The allocation API returns null (instead of an empty object) as the set
of days without allocation data, e.g. for windows reaching further back
than the metric history:
{"code":200,"data":[null]}
The allocation report, the cost allocation chart and the cost allocation
table called Object.values(set) on those sets, which throws
Cannot convert undefined or null to object
and crashes the whole view. The legacy UI handled null sets gracefully
(lodash forEach on null is a no-op), the new UI regressed on this.
Guard the remaining unguarded call sites with "set ?? {}", consistent
with the existing guard in runAllocationReport.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Markus Heiden <markus@markusheiden.de>
✅ Deploy Preview for opencost-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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 PR change?
The allocation API returns null (instead of an empty object) as the set of days without allocation data, e.g. for windows reaching further back than the metric history:
The allocation report, the cost allocation chart and the cost allocation table called Object.values(set) on those sets, which throws
and crashes the whole view. The legacy UI handled null sets gracefully (lodash forEach on null is a no-op), the new UI regressed on this.
Guard the remaining unguarded call sites with "set ?? {}", consistent with the existing guard in runAllocationReport.
Does this PR relate to any other PRs?
opencost/opencost#4004
How will this PR impact users?
No impact.
Does this PR address any GitHub or Zendesk issues?
No.
How was this PR tested?
No tests.
Does this PR require changes to documentation?
No.
Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next OpenCost release? If not, why not?
Don't know.
AI
This PR was created using Claude Code because I don't know Go. So I hope it meets your standards.