{"record":{"id":"781734d0c37cef10","repo":"different-ai/openwork","slug":"unknown-error","errorCode":null,"errorMessage":"Unknown error","messagePattern":"Unknown error","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/app/lib/opencode-session.ts","lineNumber":262,"sourceCode":"  } catch {\n    return [];\n  }\n}\n\n// ---------------------------------------------------------------------------\n// Internal\n// ---------------------------------------------------------------------------\n\nfunction assertNoClientError(result: unknown): void {\n  const maybe = result as { error?: unknown } | null | undefined;\n  if (!maybe || maybe.error === undefined) return;\n  const message =\n    maybe.error instanceof Error\n      ? maybe.error.message\n      : typeof maybe.error === \"string\"\n        ? maybe.error\n        : JSON.stringify(maybe.error);\n  throw new Error(message || \"Unknown error\");\n}\n","sourceCodeStart":244,"sourceCodeEnd":264,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/app/lib/opencode-session.ts#L244-L264","documentation":"assertNoClientError normalizes an error attached to an opencode session result (Error instance, plain string, or arbitrary value stringified via JSON.stringify) into a thrown Error. When the error value serializes to an empty string, the fallback message \"Unknown error\" is used. Called by compactSession and shellInSession.","triggerScenarios":"An opencode client call (compact, shell) returns a result object whose `error` field is set but produces an empty message — e.g. `error: \"\"`, `error: null` with truthiness already checked, or an object that stringifies to empty.","commonSituations":"Server-side failure with no message body, aborted request where the SDK sets a bare error flag, or schema drift where the error payload moved to a different field.","solutions":["Log the full result object before this assertion to see what the error actually contains.","Check the opencode server logs for the request that failed; the message was likely lost client-side.","Inspect opencode SDK version for changed error payload shape and update the extraction to read the right field."],"exampleFix":"// before: stringify loses detail\n: JSON.stringify(maybe.error);\n// after: include raw payload for diagnosis\nthrow new Error(message || `Unknown error: ${JSON.stringify(maybe.error ?? null)}`);","handlingStrategy":"try-catch","validationCode":"if (result && typeof result === \"object\" && \"error\" in result && result.error != null) {\n  console.debug(\"session error payload:\", result.error); // inspect before assert throws\n}","typeGuard":"function hasMeaningfulError(e: unknown): e is { error: string | Error } {\n  if (e == null) return false;\n  if (e instanceof Error) return e.message.length > 0;\n  if (typeof e === \"string\") return e.length > 0;\n  return JSON.stringify(e) !== \"{}\";\n}","tryCatchPattern":"try {\n  await compactSession(sessionId);\n} catch (err) {\n  if (err instanceof Error && err.message === \"Unknown error\") {\n    // message was lost; re-read session state / check server logs\n    await refreshSessionFromServer(sessionId);\n  } else throw err;\n}","preventionTips":["Check opencode server health before session-mutating calls.","Keep client SDK and server versions aligned to avoid empty error payloads.","Log raw result objects when error messages are empty to preserve diagnostics."],"tags":["opencode","session","error-handling"],"backgroundTag":"unknown-error-fallback","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}