{"record":{"id":"eb3c61524e799a3c","repo":"different-ai/openwork","slug":"sign-in-to-openwork-cloud-then-try-reconnecting-a","errorCode":null,"errorMessage":"Sign in to OpenWork Cloud, then try reconnecting again.","messagePattern":"Sign in to OpenWork Cloud, then try reconnecting again\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/session/surface/session-surface.tsx","lineNumber":2353,"sourceCode":"    };\n    window.addEventListener(denSettingsChangedEvent, resetReconnectState);\n    window.addEventListener(CLOUD_INVENTORY_CHANGED_EVENT, refreshImportedPlugins);\n    return () => {\n      window.removeEventListener(denSettingsChangedEvent, resetReconnectState);\n      window.removeEventListener(CLOUD_INVENTORY_CHANGED_EVENT, refreshImportedPlugins);\n    };\n  }, []);\n\n  const handleMcpReconnect = useCallback(async (\n    action: ChatToolReconnectAction,\n    onProgress: (progress: ChatToolReconnectProgress) => void,\n  ): Promise<ChatToolReconnectResult> => {\n    const settings = readDenSettings();\n    const token = settings.authToken?.trim() ?? \"\";\n    const organizationId = settings.activeOrgId?.trim() ?? \"\";\n    if (!token || !organizationId) {\n      props.onOpenConnect();\n      throw new Error(\"Sign in to OpenWork Cloud, then try reconnecting again.\");\n    }\n\n    const scope: ChatMcpReconnectScope = {\n      baseUrl: settings.baseUrl,\n      token,\n      organizationId,\n    };\n    const currentScope = (): ChatMcpReconnectScope => {\n      const current = readDenSettings();\n      return {\n        baseUrl: current.baseUrl,\n        token: current.authToken?.trim() ?? \"\",\n        organizationId: current.activeOrgId?.trim() ?? \"\",\n      };\n    };\n    try {\n      const denClient = createDenClient({ baseUrl: settings.baseUrl, token });\n      const connections = await denClient.listMcpConnections(organizationId, \"usable\");","sourceCodeStart":2335,"sourceCodeEnd":2371,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/session/surface/session-surface.tsx#L2335-L2371","documentation":"The chat MCP reconnect flow requires Den (OpenWork Cloud) credentials: an auth token and an active organization id read from readDenSettings(). If either is missing or blank, the flow cannot authenticate to the Den API, so it opens the connect dialog (props.onOpenConnect()) and throws to abort the reconnect.","triggerScenarios":"Invoking the chat tool reconnect handler when settings.authToken is empty/whitespace or settings.activeOrgId is unset — i.e. the user is not signed in to OpenWork Cloud or no organization is active.","commonSituations":"User signed out of Den or token expired; desktop app never connected to OpenWork Cloud; activeOrgId cleared after org switch/removal; reconnect attempted from a stale session surface after settings reset.","solutions":["Sign in to OpenWork Cloud (the error already opens the connect dialog — complete the sign-in)","Verify readDenSettings() returns a non-empty authToken and activeOrgId before retrying reconnect","If the token exists but reconnect still fails, re-authenticate to refresh an expired token","Persist/re-select an active organization in Den settings"],"exampleFix":"// before\nawait reconnectTool({ connectionId });\n// after\nconst settings = readDenSettings();\nif (!settings.authToken?.trim() || !settings.activeOrgId?.trim()) {\n  props.onOpenConnect(); // complete sign-in, then retry\n  return;\n}\nawait reconnectTool({ connectionId });","handlingStrategy":"validation","validationCode":"const settings = readDenSettings();\nconst ready = Boolean(settings.authToken?.trim() && settings.activeOrgId?.trim());\nif (!ready) props.onOpenConnect();","typeGuard":null,"tryCatchPattern":"try {\n  await reconnect(action);\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"Sign in to OpenWork Cloud\")) {\n    openConnectDialog(); // user completes sign-in, then retries\n  } else throw e;\n}","preventionTips":["Check Den auth state before rendering reconnect actions","Listen for token expiry/sign-out events and clear reconnectable actions","Always ensure an active organization is selected before Den calls","Retry reconnect only after the connect dialog flow completes"],"tags":["auth","cloud","den"],"backgroundTag":"missing-auth-token","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}