{"record":{"id":"eabcc0e7d8f065fd","repo":"different-ai/openwork","slug":"failures-join-n","errorCode":null,"errorMessage":"failures.join(\"\\n\")","messagePattern":"failures\\.join\\(\"\\\\n\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/connections/provider-auth/store.ts","lineNumber":2075,"sourceCode":"        failures.push(recordCloudProviderSyncError(liveProvider.id, reason, error));\n      }\n    }\n\n    await refreshProvidersAfterCloudSync(\n      configChanged ? { dispose: true } : { force: true },\n    ).catch(() => null);\n\n    // Notify the UI about newly imported providers so the global toast\n    // can be shown regardless of which route is active.\n    if (newlyImported.length > 0) {\n      dispatchNewProviders({\n        providers: newlyImported,\n        source: reason === \"sign_in\" ? \"sign_in\" : \"cloud_sync\",\n      });\n    }\n\n    if (failures.length > 0) {\n      throw new Error(failures.join(\"\\n\"));\n    }\n  }\n\n  async function runCloudProviderSync(reason: CloudProviderSyncReason) {\n    if (!hasCloudProviderSyncPrerequisites()) {\n      if (reason === \"settings_cloud_opened\") {\n        setStateField(\"providerAuthError\", null);\n      }\n      return;\n    }\n    if (getOpenworkGatewayOrigin()) {\n      if (!loggedGatewayCloudProviderSyncSkip) {\n        loggedGatewayCloudProviderSyncSkip = true;\n        console.info(\n          `[cloud-provider-sync:${reason}] Provider materialization is handled server-side in gateway mode.`,\n        );\n      }\n      return { outcome: \"handled_server_side\" };","sourceCodeStart":2057,"sourceCodeEnd":2093,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/connections/provider-auth/store.ts#L2057-L2093","documentation":"After a bulk cloud provider sync the store collects per-provider failure messages; if any failures accumulated it throws a single Error whose message is all failures joined by newlines. This surfaces aggregate sync problems (auth, missing credentials, server unavailability per provider) to the caller.","triggerScenarios":"runCloudProviderSync/import flow where one or more providers fail to import or sync — e.g. mixed causes like CloudProviderNeedsCredentialError for one provider and a network error for another; the joined message is the final thrown error.","commonSituations":"Org with several cloud providers where only some have valid credentials; transient network failures during bulk sync; partial server outages.","solutions":["Read the multi-line error message to identify which providers failed and fix each cause (missing org credentials, server availability).","Catch the error and log/aggregate per-provider failures in the UI instead of failing silently.","Re-run sync after fixing the failing providers; successfully imported ones are not retried as imports.","Ensure org credentials and server connectivity are healthy before bulk sync."],"exampleFix":"// before\nawait store.syncCloudProviders(); // throws joined failure list\n// after\ntry {\n  await store.syncCloudProviders();\n} catch (e) {\n  const perProvider = String(e.message).split(\"\\n\");\n  perProvider.forEach(showProviderFailure);\n}","handlingStrategy":"try-catch","validationCode":"const s = readDenSettings();\nconst ready = Boolean(s.authToken?.trim()) && Boolean(s.activeOrgId?.trim())\n  && openworkServer.getSnapshot().openworkServerClient != null;\nif (!ready) fixPrerequisitesBeforeSync();","typeGuard":"null","tryCatchPattern":"try {\n  await store.syncCloudProviders();\n} catch (e) {\n  const failures = String((e as Error).message).split(\"\\n\");\n  failures.forEach((f) => logProviderFailure(f));\n}","preventionTips":["Split the joined multi-line message to attribute failures per provider","Verify org credentials and server connectivity before bulk sync","Aggregate and display per-provider failures instead of a raw throw","Re-run sync incrementally after fixing failing providers"],"tags":["cloud","sync","aggregated-errors"],"backgroundTag":"bulk-sync-partial-failure","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}