Skip to content

Commit eec6203

Browse files
committed
fix: add validation logging for data quality issues
1. **FaultsDashboard.tsx**: Add warning for unexpected entity types - Explicitly handle 'component'/'components' case before fallback - Log console.warn when unknown entity type is encountered - Helps identify bugs where unexpected entity types are passed - Maintains existing default behavior while improving debuggability 2. **store.ts**: Add validation for malformed function data - Validate fn.id exists and is string or number before mapping - Warn when both fn.name and fn.id are missing - Prevents data quality issues from being silently masked - Aids debugging when API returns unexpected function data structure - Preserves existing fallback behavior ('Unknown', String(fn.id))
1 parent c100eb0 commit eec6203

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/components/FaultsDashboard.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ function mapFaultEntityTypeToResourceType(entityType: string): SovdResourceEntit
4444
if (type === 'area' || type === 'areas') return 'areas';
4545
if (type === 'app' || type === 'apps') return 'apps';
4646
if (type === 'function' || type === 'functions') return 'functions';
47-
// Default to components for 'component', 'components', or unknown types
47+
if (type === 'component' || type === 'components') return 'components';
48+
49+
// Log unexpected entity types to aid debugging
50+
console.warn(
51+
'[FaultsDashboard] Unexpected fault entity_type received:',
52+
entityType,
53+
'- defaulting to "components".'
54+
);
4855
return 'components';
4956
}
5057

src/lib/store.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,14 @@ export const useAppStore = create<AppState>()(
593593
// Functional view: Functions -> Apps (hosts)
594594
const functions = await client.listFunctions().catch(() => [] as SovdFunction[]);
595595
children = functions.map((fn: SovdFunction) => {
596+
// Validate function data quality
597+
if (!fn.id || (typeof fn.id !== 'string' && typeof fn.id !== 'number')) {
598+
console.warn('[Store] Malformed function data - missing or invalid id:', fn);
599+
}
600+
if (!fn.name && !fn.id) {
601+
console.warn('[Store] Malformed function data - missing both name and id:', fn);
602+
}
603+
596604
const fnName = typeof fn.name === 'string' ? fn.name : fn.id || 'Unknown';
597605
const fnId = typeof fn.id === 'string' ? fn.id : String(fn.id);
598606
return {

0 commit comments

Comments
 (0)