fix: guard session_ids with optional chaining to prevent crash
boulderState?.session_ids.includes() only guards boulderState, not session_ids. If boulder.json is corrupted or missing the field, session_ids is undefined and .includes() crashes silently, losing subagent results. Changes: - readBoulderState: validate parsed JSON is object, default session_ids to [] - atlas hook line 427: boulderState?.session_ids?.includes - atlas hook line 655: boulderState?.session_ids?.includes - prometheus-md-only line 93: boulderState?.session_ids?.includes - appendSessionId: guard with ?. and initialize to [] if missing Fixes #1672
This commit is contained in:
@@ -43,7 +43,7 @@ export function getAgentFromSession(sessionID: string, directory: string): strin
|
||||
|
||||
// Check boulder state (persisted across restarts) - fixes #927
|
||||
const boulderState = readBoulderState(directory)
|
||||
if (boulderState?.session_ids.includes(sessionID) && boulderState.agent) {
|
||||
if (boulderState?.session_ids?.includes(sessionID) && boulderState.agent) {
|
||||
return boulderState.agent
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user