{"record":{"id":"6be7b18f8c911bc6","repo":"stablyai/orca","slug":"session-not-found-sessionid-6be7b1","errorCode":null,"errorMessage":"Session not found: ${sessionId}","messagePattern":"Session not found: (.+?)","errorType":"exception","errorClass":"SessionNotFoundError","httpStatus":null,"severity":"error","filePath":"src/main/daemon/degraded-daemon-session-routing.ts","lineNumber":24,"sourceCode":"  sessionProviders: ReadonlyMap<string, IPtyProvider>,\n  provider: IPtyProvider\n): string[] {\n  return [...sessionProviders]\n    .filter(([, mappedProvider]) => mappedProvider === provider)\n    .map(([id]) => id)\n}\n\n/** Attach-only session adoption: refuses the in-process fallback route. A\n *  fallback pty cannot own a daemon-surviving session by definition, and its\n *  no-op attach resolving would pin a subscriber-driven attach as succeeded\n *  while the stream stays blank. */\nexport async function attachDaemonOwnedSession(\n  owner: IPtyProvider,\n  fallback: IPtyProvider,\n  sessionId: string\n): ReturnType<IPtyProvider['attach']> {\n  if (owner === fallback) {\n    throw new SessionNotFoundError(sessionId)\n  }\n  return await owner.attach(sessionId)\n}\n\n/** Probes providers for an id absent from the routing map and adopts the\n *  first proven owner into the map. */\nexport function adoptOwningProvider(\n  sessionProviders: Map<string, IPtyProvider>,\n  providers: readonly IPtyProvider[],\n  sessionId: string\n): IPtyProvider | null {\n  for (const provider of providers) {\n    if (provider.hasPty?.(sessionId) === true) {\n      sessionProviders.set(sessionId, provider)\n      return provider\n    }\n  }\n  return null","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/daemon/degraded-daemon-session-routing.ts#L6-L42","documentation":"SessionNotFoundError from attachDaemonOwnedSession: an attach-only adoption was attempted against the in-process fallback PTY provider (owner === fallback). By definition a fallback pty cannot own a daemon-surviving session, and its no-op attach would falsely report success while the stream stays blank. The attach is refused so the caller seeks the real daemon owner.","triggerScenarios":"attachDaemonOwnedSession(owner, fallback, sessionId) called where the session's route maps to the fallback provider (e.g., the daemon adapter is down and the session was degraded to the fallback), with attachOnly semantics.","commonSituations":"The daemon host is unavailable so sessions fell back to an in-process pty; an attach-only request arrives for one of those fallback sessions; a routing map pointing a daemon-surviving session id at the fallback provider.","solutions":["Reconnect to the real daemon adapter and re-resolve the session owner before attaching.","Do not mark daemon-owned session ids as owned by the fallback provider; keep the routing map accurate.","If the daemon is permanently gone, create a fresh session rather than attach-adopting a fallback id.","Validate that the resolved owner is not the fallback before calling attachDaemonOwnedSession."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Ensure the owner is a real daemon adapter, not the fallback, before attach-only\nif (owner === fallback) {\n  // reconnect to the daemon and re-resolve instead of attaching\n  await reconnectDaemonAdapter()\n}","typeGuard":"function isFallbackOwner(owner: IPtyProvider, fallback: IPtyProvider): boolean {\n  return owner === fallback\n}","tryCatchPattern":"try {\n  return await attachDaemonOwnedSession(owner, fallback, sessionId)\n} catch (e) {\n  if (e instanceof SessionNotFoundError && owner === fallback) {\n    const real = await resolveDaemonOwner(sessionId)\n    return await attachDaemonOwnedSession(real, fallback, sessionId)\n  }\n  throw e\n}","preventionTips":["Never route daemon-surviving session ids to the in-process fallback provider.","Reconnect to the daemon adapter and re-resolve ownership before attach-only.","If the daemon is permanently gone, create a fresh session rather than attaching a fallback id."],"tags":["session","fallback","degraded","attach"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}