{"record":{"id":"80205460d30561f8","repo":"different-ai/openwork","slug":"sign-in-to-openwork-cloud-and-choose-an-organizati-802054","errorCode":null,"errorMessage":"Sign in to OpenWork Cloud and choose an organization first.","messagePattern":"Sign in to OpenWork Cloud and choose an organization first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/connections/store.ts","lineNumber":761,"sourceCode":"      finishPerf(options.developerMode(), \"mcp.connect\", \"blocked\", startedAt, {\n        reason: \"openwork-connect-name-reserved\",\n      });\n      return { ok: false, error };\n    }\n\n    try {\n      mutateState((current) => ({ ...current, mcpStatus: null, mcpConnectingName: entry.name }));\n\n      if (entry.managedBy === \"openwork-connect\") {\n        if (slug !== CLOUD_MCP_SERVER_NAME) {\n          throw new Error(\"OpenWork Connect MCP metadata is invalid.\");\n        }\n        if (!canUseOpenworkServer || !openworkClient || !openworkWorkspaceId) {\n          throw new Error(\"OpenWork server is required to repair agent access to connected services.\");\n        }\n        const context = await resolveCloudMcpOperationContext(entry.url);\n        if (!context) {\n          throw new Error(\"Sign in to OpenWork Cloud and choose an organization first.\");\n        }\n        clearCloudMcpDisabledIntent(context);\n        const result = await runOpenworkCloudMcpReconciler({\n          mode: \"repair\",\n          client: openworkClient,\n          context: { ...context, trigger: \"desktop-explicit-connect\" },\n          mintToken: mintCloudControlMcpToken,\n          force: true,\n          refreshMarginMs: CLOUD_MCP_REFRESH_MARGIN_MS,\n        });\n        await refreshMcpServers();\n        if (result.health?.usable) {\n          setStateField(\"mcpStatus\", t(\"mcp.connected\"));\n          finishPerf(options.developerMode(), \"mcp.connect\", \"done\", startedAt, {\n            name: entry.name,\n            type: entryType,\n            slug,\n          });","sourceCodeStart":743,"sourceCodeEnd":779,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/connections/store.ts#L743-L779","documentation":"After the server prerequisite check, the repair path calls resolveCloudMcpOperationContext(entry.url) to obtain the Den/cloud operation context (org, auth, routing). If it returns null — the user is not authenticated to OpenWork Cloud or has not picked an organization — the store throws 'Sign in to OpenWork Cloud and choose an organization first.'","triggerScenarios":"Repairing an openwork-connect MCP entry while the Den session is absent, expired, or has no organization selected, so resolveCloudMcpOperationContext cannot build a context for the entry URL.","commonSituations":"Expired OpenWork Cloud token mid-session; a fresh install where the user connected services previously but never signed in on this machine; switching Den orgs and the cached context no longer resolves.","solutions":["Sign in to OpenWork Cloud (Account → Sign in flow) and select an organization, then retry the repair","Re-authenticate if the Den session token expired","Trigger the connect action again after the sign-in completes so the context resolves","Verify resolveCloudMcpOperationContext can reach the Den endpoint (network/auth configuration)"],"exampleFix":"// before\nawait connectionsStore.connect(entry);\n// after\nconst ctx = await resolveCloudMcpOperationContext(entry.url);\nif (!ctx) {\n  await promptOpenworkCloudSignIn(); // sign in + choose org\n}\nawait connectionsStore.connect(entry);","handlingStrategy":"try-catch","validationCode":"const ctx = await resolveCloudMcpOperationContext(entry.url);\nif (!ctx) { await promptOpenworkCloudSignIn(); return; }","typeGuard":"function hasCloudContext(c: CloudMcpOperationContext | null): c is CloudMcpOperationContext {\n  return c != null && typeof c.orgId === \"string\";\n}","tryCatchPattern":"try {\n  await connectionsStore.connect(entry);\n} catch (err) {\n  if (err.message.startsWith(\"Sign in to OpenWork Cloud\")) {\n    await startCloudSignInFlow(); // re-auth + org selection, then retry\n  } else throw err;\n}","preventionTips":["Check Den auth state before initiating managed MCP repairs","Handle expired tokens by re-running sign-in instead of failing silently","Prompt for organization selection on first connect in a fresh install","Catch this message in the connect handler and launch the sign-in flow"],"tags":["auth","sign-in","organization","openwork-cloud"],"backgroundTag":"authentication-required","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}