{"record":{"id":"100537b62d021e24","repo":"different-ai/openwork","slug":"serializesdkerror-result-error-100537","errorCode":null,"errorMessage":"serializeSDKError(result.error)","messagePattern":"serializeSDKError\\(result\\.error\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/shell/session-route.tsx","lineNumber":1341,"sourceCode":"                    label: modelSelection,\n                  },\n                ];\n                trackSessionActive(targetSessionId, telemetryDimensions);\n                trackTaskStarted(targetSessionId, telemetryDimensions);\n\n                if (draft.mode === \"shell\") {\n                  await shellInSession(opencodeClient, targetSessionId, text);\n                  return;\n                }\n\n                if (draft.command) {\n                  const result = await opencodeClient.session.command({\n                    sessionID: targetSessionId,\n                    command: draft.command.name,\n                    arguments: draft.command.arguments,\n                  });\n                  if (result.error) {\n                    throw new Error(serializeSDKError(result.error));\n                  }\n                  return;\n                }\n\n                const parts = await draftToParts(draft, selectedWorkspaceRoot, targetSessionId, selectedWorkspaceEndpoint);\n                const envSystemContext = await buildOpenworkEnvSystemContext(client, {\n                  cacheKey: targetSessionId,\n                  runtimeKey: environmentRuntimeKey,\n                });\n                const result = await opencodeClient.session.promptAsync({\n                  sessionID: targetSessionId,\n                  parts,\n                  model: sendModel ?? undefined,\n                  agent: selectedAgent ?? undefined,\n                  ...(sendVariant ? { variant: sendVariant } : {}),\n                  ...(envSystemContext ? { system: envSystemContext } : {}),\n                });\n                if (result.error) {","sourceCodeStart":1323,"sourceCodeEnd":1359,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/shell/session-route.tsx#L1323-L1359","documentation":"When a slash-command draft is submitted, the UI calls opencodeClient.session.command() against the primary endpoint. The SDK returns a result envelope; a non-null result.error means the server rejected the command. The UI serializes that SDK error (serializeSDKError, session-route.tsx:254) into a thrown Error so it surfaces in the normal send-error path.","triggerScenarios":"Submitting a draft with draft.command set where opencodeClient.session.command() returns { error } — unknown command name, command failed server-side, invalid arguments, or session no longer exists.","commonSituations":"Typing a custom command that the server's command list no longer defines; passing wrong-typed arguments to a command; session was reverted/deleted between draft and submit; server version mismatch after an app update.","solutions":["Read the serialized error text for the server's reason (unknown command vs. execution failure)","Verify the command name exists in the workspace's command configuration","Check the session still exists and retry; start a new session if it was deleted","Update the app if the client and server versions are mismatched"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const known = await opencodeClient.command.list();\nif (!known.data?.some((c) => c.name === draft.command.name)) {\n  notify(`Unknown command: ${draft.command.name}`);\n  return;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await opencodeClient.session.command({ sessionID, command, arguments });\n  if (result.error) throw new Error(serializeSDKError(result.error));\n} catch (e) {\n  showErrorToast(String((e as Error).message));\n}","preventionTips":["Validate command names against the server's command list before submit","Keep client and server versions in sync","Confirm the session exists before sending commands"],"tags":["sdk","command","server-error"],"backgroundTag":"sdk-command-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}