{"record":{"id":"43d37281a6797fbc","repo":"different-ai/openwork","slug":"this-cloud-provider-has-not-been-imported-into-the","errorCode":null,"errorMessage":"This cloud provider has not been imported into the workspace.","messagePattern":"This cloud provider has not been imported into the workspace\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/connections/provider-auth/store.ts","lineNumber":1811,"sourceCode":"      const result = await connectCloudProviderInternal(cloudProviderId);\n      setCloudProviderSyncError(cloudProviderId, null);\n      return result;\n    } catch (error) {\n      setCloudProviderSyncError(cloudProviderId, describeCloudProviderSyncError(error));\n      throw error;\n    }\n  }\n\n  async function removeCloudProviderInternal(\n    cloudProviderId: string,\n    optionsArg?: { silent?: boolean },\n  ) {\n    if (!optionsArg?.silent) {\n      setStateField(\"providerAuthError\", null);\n    }\n    const imported = state.importedCloudProviders[cloudProviderId];\n    if (!imported) {\n      throw new Error(\"This cloud provider has not been imported into the workspace.\");\n    }\n\n    try {\n      try {\n        await removeProviderAuthCredentials(imported.providerId);\n      } catch (error) {\n        const message = error instanceof Error ? error.message : String(error ?? \"\");\n        if (!/not found|unknown auth|404/i.test(message.toLowerCase())) {\n          throw error;\n        }\n      }\n      // Runtime-managed: delete the provider entry via the server's per-key\n      // merge (`null` deletes), then strip any legacy opencode.jsonc block\n      // left by pre-runtime builds. Both are idempotent.\n      await patchRuntimeProviders({ [imported.providerId]: null });\n      await stripLegacyCloudProviderBlocks([imported.providerId]);\n\n      const nextImportedProviders = { ...state.importedCloudProviders };","sourceCodeStart":1793,"sourceCodeEnd":1829,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/connections/provider-auth/store.ts#L1793-L1829","documentation":"Removing a cloud provider requires it to have been previously imported; the store looks up state.importedCloudProviders[cloudProviderId] and throws this error when no record exists. Without an import record there are no local provider credentials to remove, so the operation is refused.","triggerScenarios":"Calling the remove-cloud-provider action with an id never imported in this workspace, after the imported map was reset (app state cleared/reloaded), or with a mistyped/duplicated cloudProviderId.","commonSituations":"UI stale after state reset showing a provider that is no longer imported; double-remove after a first successful removal; tests using an arbitrary id without seeding importedCloudProviders.","solutions":["Check state.importedCloudProviders[cloudProviderId] exists before calling the remove action.","Refresh the cloud provider list from the store so the UI only shows imported providers.","Guard against double-removal by disabling the remove button once the provider is gone.","In tests, seed the store's importedCloudProviders before invoking removal."],"exampleFix":"// before\nawait store.removeCloudProvider(cloudProviderId);\n// after\nif (!store.getState().importedCloudProviders[cloudProviderId]) return; // nothing to remove\nawait store.removeCloudProvider(cloudProviderId);","handlingStrategy":"validation","validationCode":"const imported = store.getState().importedCloudProviders[cloudProviderId];\nif (!imported) return; // nothing to remove","typeGuard":"function isImported(state: { importedCloudProviders: Record<string, unknown> }, id: string): boolean {\n  return Boolean(state.importedCloudProviders[id]);\n}","tryCatchPattern":"try {\n  await store.removeCloudProvider(cloudProviderId);\n} catch (e) {\n  if (String((e as Error).message).includes(\"not been imported\")) {\n    refreshProviderList();\n  }\n}","preventionTips":["Drive remove buttons from the live importedCloudProviders map","Disable remove for non-imported providers","Handle double-click/double-remove idempotently in the UI","Seed imported providers in tests before removal"],"tags":["state","cloud","validation"],"backgroundTag":"resource-not-found","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}