Skip to content

Commit a0508b0

Browse files
vsilentCopilot
andcommitted
web: guard ThreatMap against missing stats buckets
Handle absent byType/bySeverity in API responses to prevent runtime Object.entries(undefined) crashes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3e6cae5 commit a0508b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

web/src/components/ThreatMap.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ const ThreatMap: React.FC = () => {
3636

3737
const getTypeData = () => {
3838
if (!statistics) return [];
39-
return Object.entries(statistics.byType).map(([name, value]) => ({
39+
const byType = statistics.byType || {};
40+
return Object.entries(byType).map(([name, value]) => ({
4041
name,
4142
value,
4243
}));
4344
};
4445

4546
const getSeverityData = () => {
4647
if (!statistics) return [];
47-
return Object.entries(statistics.bySeverity).map(([name, value]) => ({
48+
const bySeverity = statistics.bySeverity || {};
49+
return Object.entries(bySeverity).map(([name, value]) => ({
4850
name,
4951
value,
5052
}));

0 commit comments

Comments
 (0)