{"record":{"id":"905c3868fc4ff2fd","repo":"different-ai/openwork","slug":"sign-in-to-openwork-cloud-and-choose-an-organizati","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/provider-auth/store.ts","lineNumber":1669,"sourceCode":"  }\n\n  async function connectCloudProviderInternal(\n    cloudProviderId: string,\n    optionsArg?: { silent?: boolean },\n  ) {\n    if (!optionsArg?.silent) {\n      setStateField(\"providerAuthError\", null);\n    }\n    const c = options.client();\n    if (!c) {\n      throw new Error(t(\"providers.not_connected\"));\n    }\n\n    const settings = readDenSettings();\n    const token = settings.authToken?.trim() ?? \"\";\n    const orgId = settings.activeOrgId?.trim() ?? \"\";\n    if (!token || !orgId) {\n      throw new Error(\"Sign in to OpenWork Cloud and choose an organization first.\");\n    }\n\n    try {\n      const den = createDenClient({\n        baseUrl: settings.baseUrl,\n        token,\n      });\n      const provider = await den.getOrgLlmProviderConnection(orgId, cloudProviderId);\n      const localProviderId = getCloudManagedProviderId(provider);\n      assertProviderAllowedByDesktopPolicy(localProviderId);\n      const existingImported = state.importedCloudProviders[cloudProviderId] ?? null;\n      const { envEntries, primaryApiKey } = resolveCloudProviderCredentials(provider);\n      const env = getCloudProviderEnv(provider.providerConfig);\n      if (!primaryApiKey && env.length > 0) {\n        throw new CloudProviderNeedsCredentialError(\n          `${provider.name} does not have a stored organization credential yet.`,\n        );\n      }","sourceCodeStart":1651,"sourceCodeEnd":1687,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/connections/provider-auth/store.ts#L1651-L1687","documentation":"When pushing Den session state the store reads saved OpenWork Cloud (Den) settings and requires both an auth token and an active organization id. If either is missing or blank it throws this plain-text guidance error, because org-scoped cloud operations cannot proceed unauthenticated.","triggerScenarios":"Calling the Den push/sync action before signing in to OpenWork Cloud, after signing out (token cleared), or when no organization has been selected so activeOrgId is empty.","commonSituations":"Fresh install with no Den sign-in; token expired/cleared from settings; user picked a server but never chose an org; settings file read from the wrong profile.","solutions":["Sign in to OpenWork Cloud and select an organization in Settings before triggering cloud provider actions.","Check readDenSettings() output for authToken and activeOrgId before invoking the action.","Re-run the sign-in flow if the token was cleared or expired.","Ensure the correct settings profile/config file is being loaded."],"exampleFix":"// before\nawait store.pushDenSession(); // throws without token/org\n// after\nconst s = readDenSettings();\nif (!s.authToken?.trim() || !s.activeOrgId?.trim()) {\n  await openCloudSignInDialog();\n  return;\n}\nawait store.pushDenSession();","handlingStrategy":"validation","validationCode":"const s = readDenSettings();\nconst authed = Boolean(s.authToken?.trim()) && Boolean(s.activeOrgId?.trim());\nif (!authed) openCloudSignInDialog();","typeGuard":"function isDenAuthenticated(s: { authToken?: string | null; activeOrgId?: string | null }): boolean {\n  return Boolean(s.authToken?.trim()) && Boolean(s.activeOrgId?.trim());\n}","tryCatchPattern":"try {\n  await store.pushDenSession();\n} catch (e) {\n  if (String((e as Error).message).includes(\"Sign in to OpenWork Cloud\")) {\n    startCloudSignInFlow();\n  }\n}","preventionTips":["Check Den auth state before exposing cloud actions in the UI","Handle sign-out by clearing dependent UI state","Prompt org selection as part of onboarding","Refresh the token proactively when nearing expiry"],"tags":["auth","cloud","configuration"],"backgroundTag":"not-authenticated","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}