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:
gsxdsm
2026-05-19 17:48:23 -07:00
parent 2a8e6574de
commit d9f105baf2

View File

@@ -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,