Skip to content

Commit 8dd44e1

Browse files
author
jackn
committed
fix: Handle non-array API responses in Configurator
Prevents crash when API returns error object (e.g. UNAUTHORIZED) instead of array. Gracefully sets empty array and logs error.
1 parent beb1af7 commit 8dd44e1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

frontend/src/pages/Configurator.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ function Configurator() {
106106
const response = await fetch("/api/v1/configurator/templates");
107107
if (!response.ok) throw new Error("Failed to fetch templates");
108108
const data = await response.json();
109+
if (!Array.isArray(data)) {
110+
console.error("Invalid templates response:", data);
111+
setTemplates([]);
112+
return;
113+
}
109114
setTemplates(data);
110115
setError(null);
111116
} catch (err) {

0 commit comments

Comments
 (0)