{"record":{"id":"e6b1b080b1aded7e","repo":"chatboxai/chatbox","slug":"unknown-session-type-session-type-generate-fa","errorCode":null,"errorMessage":"Unknown session type: ${session.type}, generate failed","messagePattern":"Unknown session type: (.+?), generate failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/stores/session/pictures.ts","lineNumber":109,"sourceCode":"          message: userMessage,\n          num: settings.imageGenerateNum || 1,\n        },\n        async (picBase64) => {\n          const storageKey = StorageKeyGenerator.picture(`${session.id}:${targetMsg.id}:${imageIndex++}`)\n          // Image needs to be stored in indexedDB, if using OpenAI's image link directly, the link will expire over time\n          await storage.setBlob(storageKey, picBase64)\n          await insertImage({ type: 'image', storageKey })\n        }\n      )\n      targetMsg = {\n        ...targetMsg,\n        generating: false,\n        cancel: undefined,\n        status: [],\n      }\n      await modifyMessage(sessionId, targetMsg, true)\n    } else {\n      throw new Error(`Unknown session type: ${session.type}, generate failed`)\n    }\n    appleAppStore.tickAfterMessageGenerated()\n  } catch (err: unknown) {\n    targetMsg = handleGenerationError(err, targetMsg, settings)\n    await modifyMessage(sessionId, targetMsg, true)\n  }\n}\n","sourceCodeStart":91,"sourceCodeEnd":117,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/stores/session/pictures.ts#L91-L117","documentation":"orchestratePictureGeneration only knows how to handle session.type === 'picture'; any other type reaching the final else branch throws. This is a routing assertion — the function should only be entered for picture sessions.","triggerScenarios":"orchestratePictureGeneration invoked with a session whose type is not 'picture' (e.g. 'chat', 'agent', 'memo'). The caller routed a non-picture session into the picture orchestrator.","commonSituations":"A caller dispatch bug (e.g. a switch on session.type falls through incorrectly), a new session type added without updating the orchestrator dispatch, or session.type mutated to an unexpected value.","solutions":["Fix the caller to route only picture sessions into orchestratePictureGeneration; add a type guard at the call site.","Return early for unknown types instead of throwing so a routing bug does not crash the message.","Add the new session type to the orchestrator dispatch when introducing one.","Assert session.type at the entry and log the offending caller stack."],"exampleFix":"// before\n} else {\n  throw new Error(`Unknown session type: ${session.type}, generate failed`)\n}\n// after\n} else {\n  log.error('orchestratePictureGeneration: unsupported session type', { sessionType: session.type, sessionId })\n  return\n}","handlingStrategy":"validation","validationCode":"if (session.type !== 'picture') {\n  log.error('orchestratePictureGeneration: unsupported type', { sessionType: session.type })\n  return\n}","typeGuard":"function isPictureSession(s: { type: string }): s is { type: 'picture' } {\n  return s.type === 'picture'\n}","tryCatchPattern":null,"preventionTips":["Route only picture sessions into orchestratePictureGeneration.","Return early for unknown types instead of throwing.","Update the dispatcher when adding new session types."],"tags":["picture-session","routing","session-type","dispatch"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}