fix(goals): validate the goal RPC output before returning it

This commit is contained in:
Chris Scott committed 2026-10-30 01:03:14 -04:00
1 parent cbe92c92ad
commit 5db74e3fa7
2 files changed
+13 -1

No files matched your search

+4 -1
View File
@@ -50,7 +50,10 @@ export async function readSessionGoal(
input: { sessionID: input.sessionID },
...(input.directory ? { location: { directory: input.directory } } : {}),
})
return { supported: true, goal: (result.output ?? null) as GoalState | null }
const output: unknown = result.output ?? null
if (output === null) return { supported: true, goal: null }
if (!isGoalState(output)) return { supported: false }
return { supported: true, goal: output }
} catch (error) {
if (isRpcError(error) && error.type === 'rpc.unavailable') return { supported: false }
throw error