different-ai/openwork · error · CloudProviderNeedsServerError
`${provider.name} needs environment variables (${envEntries.
Error message
`${provider.name} needs environment variables (${envEntries.map((entry) => entry.key).join(", ")}) but the OpenWork server is not available.` What it means
During cloud provider import, if the provider requires environment variables (envEntries) they must be written to the local OpenWork server via upsertUserEnv. When the OpenWork server client is unavailable the store throws CloudProviderNeedsServerError explaining which env vars are needed, and the import stops.
Source
Thrown at apps/app/src/react-app/domains/connections/provider-auth/store.ts:1694
});
const provider = await den.getOrgLlmProviderConnection(orgId, cloudProviderId);
const localProviderId = getCloudManagedProviderId(provider);
assertProviderAllowedByDesktopPolicy(localProviderId);
const existingImported = state.importedCloudProviders[cloudProviderId] ?? null;
const { envEntries, primaryApiKey } = resolveCloudProviderCredentials(provider);
const env = getCloudProviderEnv(provider.providerConfig);
if (!primaryApiKey && env.length > 0) {
throw new CloudProviderNeedsCredentialError(
`${provider.name} does not have a stored organization credential yet.`,
);
}
await assertCloudProviderImportSafe(provider);
if (envEntries.length > 0) {
const openworkClient = options.openworkServer.getSnapshot().openworkServerClient;
if (!openworkClient) {
throw new CloudProviderNeedsServerError(
`${provider.name} needs environment variables (${envEntries
.map((entry) => entry.key)
.join(", ")}) but the OpenWork server is not available.`,
);
}
await openworkClient.upsertUserEnv(envEntries);
}
if (primaryApiKey) {
await c.auth.set({
providerID: localProviderId,
auth: { type: "api", key: primaryApiKey },
});
await mirrorOpenWorkModelsVoiceEnv(provider, primaryApiKey, envEntries);
}
if (existingImported?.providerId && existingImported.providerId !== localProviderId) {
try {
await removeProviderAuthCredentials(existingImported.providerId);
} catch (error) {View on GitHub (pinned to 2b7df46e8a)
Solutions
- Start/connect the OpenWork server before importing cloud providers.
- Wait for the openworkServer snapshot to expose a client (poll or subscribe) before import.
- Catch CloudProviderNeedsServerError and retry the import once the server is available.
- If the provider does not actually need env vars, fix its providerConfig or org credential so envEntries is empty.
Example fix
// before
await store.importCloudProvider(id); // throws CloudProviderNeedsServerError
// after
await waitFor(() => openworkServer.getSnapshot().openworkServerClient, { timeoutMs: 15000 });
await store.importCloudProvider(id); Defensive patterns
Strategy: retry
Validate before calling
const client = openworkServer.getSnapshot().openworkServerClient;
if (!client && getCloudProviderEnv(provider.providerConfig).length > 0) {
await waitForServerConnection({ timeoutMs: 15000 });
} Type guard
function canUpsertEnv(s: { openworkServerClient: unknown }): boolean {
return s.openworkServerClient != null;
} Try / catch
try {
await store.importCloudProvider(cloudProviderId);
} catch (e) {
if (e instanceof CloudProviderNeedsServerError) {
await waitForServerConnection();
await store.importCloudProvider(cloudProviderId);
}
} Prevention
- Wait for server readiness before bulk imports
- Monitor server health and surface it in the UI before cloud operations
- Avoid running provider syncs in contexts without the OpenWork server
- Retry imports that fail solely due to server unavailability
When it happens
Trigger: Importing a cloud provider whose config declares required env vars while options.openworkServer.getSnapshot().openworkServerClient is null — e.g. app running without the local server, server not yet initialized, or in a browser-only context without the server.
Common situations: Cloud sync fired at startup before the server client connects; self-hosted setup where the OpenWork server is down; headless/test environments without the server wiring.
Related errors
- Invalid cloud provider sync response.
- Invalid cloud provider sync status.
- Invalid cloud provider sync status response.
- Sign in to OpenWork Cloud and choose an organization first.
- `${provider.name} does not have a stored organization creden
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/47a6b56d87d35acd.
Report an issue: GitHub.