fix(dashboard): defend MissionManager.loadMissions against non-array fetch results
When fetchMissions returns a non-array (envelope shape, error path, or mocked detail object) setMissions(data) leaks the bad shape into render, where missions.filter() throws "is not a function" and crashes the entire MissionManager test file. Coerce to [] before storing, matching the existing defenses on the useState init and cache-hydration paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -811,7 +811,10 @@ export function MissionManager({ isOpen, isInline = false, onClose, addToast, pr
|
||||
if (!hasHydratedRef.current) {
|
||||
setLoading(true);
|
||||
}
|
||||
const data = await fetchMissions(projectId);
|
||||
const fetched = await fetchMissions(projectId);
|
||||
// Defensive: API helpers can return an envelope or non-array under
|
||||
// failure paths; downstream code (render, filter) assumes an array.
|
||||
const data = Array.isArray(fetched) ? fetched : [];
|
||||
setMissions(data);
|
||||
writeCache(
|
||||
missionsCacheKey,
|
||||
|
||||
Reference in New Issue
Block a user