stablyai/orca · error · LinearWriteFailure

failed

failed

Error message

Not connected to Linear

What it means

Thrown by createIssueForAgent when getClients(workspaceId)[0] is undefined. The agent-facing create path requires a concrete, connected workspace and aborts with kind='failed' before contacting Linear. This is a precondition failure, distinct from a Linear API rejection.

Source

Thrown at src/main/linear/issues.ts:1178

  title: string,
  description: string | undefined,
  workspaceId: string,
  options: {
    id: string
    parentId?: string | null
    projectId?: string | null
    stateId?: string
    assigneeId?: string | null
    priority?: number
    estimate?: number | null
    dueDate?: string | null
    labelIds?: string[]
    signal?: AbortSignal
  }
): Promise<LinearIssueWriteRecord> {
  const entry = getClients(workspaceId)[0]
  if (!entry) {
    throw new LinearWriteFailure('failed', 'Not connected to Linear')
  }

  return runLinearWrite(entry, options.signal, async (client) => {
    const result = await client.createIssue({
      id: options.id,
      teamId,
      title,
      ...(description ? { description } : {}),
      ...(options.parentId ? { parentId: options.parentId } : {}),
      ...(options.projectId ? { projectId: options.projectId } : {}),
      ...(options.stateId ? { stateId: options.stateId } : {}),
      ...(options.assigneeId !== undefined ? { assigneeId: options.assigneeId } : {}),
      ...(options.priority !== undefined ? { priority: options.priority } : {}),
      ...(options.estimate !== undefined ? { estimate: options.estimate } : {}),
      ...(options.dueDate !== undefined ? { dueDate: options.dueDate } : {}),
      ...(options.labelIds !== undefined ? { labelIds: options.labelIds } : {})
    })
    if (!result.success) {

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Pre-check connectivity with getLinearStatus() and require connection before issuing the create call.
  2. Ensure the workspaceId passed is the same id recorded in workspace state.
  3. Handle LinearWriteFailure with kind='failed' to surface a re-auth prompt rather than retrying.

Example fix

// before
const rec = await createIssueForAgent(teamId, { title }, workspaceId, { signal })
// after
if (!getClients(workspaceId)[0]) throw new Error('Connect Linear first')
const rec = await createIssueForAgent(teamId, { title }, workspaceId, { signal })
Defensive patterns

Strategy: validation

Validate before calling

if (!getClients(workspaceId)[0]) throw new Error('Connect Linear before creating issues')

Type guard

function isNotConnectedFailure(e: unknown): boolean {
  return e instanceof LinearWriteFailure && e.kind === 'failed' && e.message === 'Not connected to Linear'
}

Try / catch

try { await createIssueForAgent(teamId, opts, workspaceId, { signal }) }
catch (e) { if (isNotConnectedFailure(e)) { await promptConnect(); return } throw e }

Prevention

When it happens

Trigger: Invoking createIssueForAgent with a workspaceId that has no loaded token, was disconnected, or whose credentials cannot be decrypted.

Common situations: Agent tool ran before the user connected Linear; the selected workspace differs from connected ones; token was cleared after an auth error on a prior call.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/450581dfab8679e8. Report an issue: GitHub.