mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
fix(goals): validate the goal RPC output before returning it
This commit is contained in:
1 parent
cbe92c92ad
commit
5db74e3fa7
2 files changed
+13
-1
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user