diff --git a/src/frontend/src/CustomNodes/GenericNode/components/outputModal/components/switchOutputView/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/outputModal/components/switchOutputView/index.tsx index c5585d116..48352f7a9 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/outputModal/components/switchOutputView/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/outputModal/components/switchOutputView/index.tsx @@ -25,8 +25,11 @@ const SwitchOutputView: React.FC = ({ const flowPoolNode = (flowPool[nodeId] ?? [])[ (flowPool[nodeId]?.length ?? 1) - 1 ]; - - const results = flowPoolNode?.data?.logs[outputName] ?? ""; + let results = flowPoolNode?.data?.logs[outputName] ?? ""; + if (Array.isArray(results)) { + console.error("Log results are an array", results); + return; + } const resultType = results?.type; let resultMessage = results?.message; const RECORD_TYPES = ["data", "object", "array", "message"]; diff --git a/src/frontend/src/types/api/index.ts b/src/frontend/src/types/api/index.ts index 273455bfd..49d94a350 100644 --- a/src/frontend/src/types/api/index.ts +++ b/src/frontend/src/types/api/index.ts @@ -179,11 +179,16 @@ export type VertexBuildTypeAPI = { messages: ChatOutputType[] | ChatInputType[]; }; +export type LogType = { + message: any; + type: string; +}; + // data is the object received by the API // it has results, artifacts, timedelta, duration export type VertexDataTypeAPI = { results: { [key: string]: string }; - logs: { message: any; type: string }[]; + logs: { [key: string]: LogType | LogType[] }; messages: ChatOutputType[] | ChatInputType[]; inactive?: boolean; timedelta?: number; diff --git a/src/frontend/src/utils/buildUtils.ts b/src/frontend/src/utils/buildUtils.ts index 8f008e149..f12d582a7 100644 --- a/src/frontend/src/utils/buildUtils.ts +++ b/src/frontend/src/utils/buildUtils.ts @@ -266,9 +266,18 @@ async function buildVertex({ const buildData: VertexBuildTypeAPI = buildRes.data; if (onBuildUpdate) { if (!buildData.valid) { + // lots is a dictionary with the key the output field name and the value the log object + // logs: { [key: string]: { message: any; type: string }[] }; + const errorMessages = Object.keys(buildData.data.logs).map((key) => { + const logs = buildData.data.logs[key]; + if (Array.isArray(logs)) { + return logs.map((log) => log.message); + } + return [logs.message]; + }); onBuildError!( "Error Building Component", - buildData.data.logs.map((log) => log.message), + errorMessages, verticesIds.map((id) => ({ id })) ); stopBuild();