{"record":{"id":"5e3b2ff5d0243cb8","repo":"different-ai/openwork","slug":"t-providers-provider-id-required","errorCode":null,"errorMessage":"t(\"providers.provider_id_required\")","messagePattern":"t\\(\"providers\\.provider_id_required\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/connections/provider-auth/store.ts","lineNumber":1414,"sourceCode":"  ): Promise<ProviderOAuthStartResult> {\n    setStateField(\"providerAuthError\", null);\n    const c = options.client();\n    if (!c) {\n      throw new Error(t(\"providers.not_connected\"));\n    }\n    try {\n      const cachedMethods = state.providerAuthMethods;\n      const authMethods = Object.keys(cachedMethods).length\n        ? cachedMethods\n        : await loadProviderAuthMethods(getProviderAuthWorkerType());\n      const providerIds = Object.keys(authMethods).sort();\n      if (!providerIds.length) {\n        throw new Error(t(\"providers.no_providers_available\"));\n      }\n\n      const resolved = providerId?.trim() ?? \"\";\n      if (!resolved) {\n        throw new Error(t(\"providers.provider_id_required\"));\n      }\n      assertProviderAllowedByDesktopPolicy(resolved);\n\n      const methods = authMethods[resolved];\n      if (!methods || !methods.length) {\n        throw new Error(`${t(\"providers.unknown_provider\")}: ${resolved}`);\n      }\n\n      const oauthIndex =\n        methodIndex !== undefined\n          ? methodIndex\n          : methods.find((method) => method.type === \"oauth\")?.methodIndex ?? -1;\n      if (oauthIndex === -1) {\n        throw new Error(\n          `${t(\"providers.no_oauth_prefix\")} ${resolved}. ${t(\"providers.use_api_key_suffix\")}`,\n        );\n      }\n","sourceCodeStart":1396,"sourceCodeEnd":1432,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/connections/provider-auth/store.ts#L1396-L1432","documentation":"startProviderOAuth accepts an optional providerId; when it is omitted, empty, or whitespace-only, the store cannot determine which provider to authenticate and throws providers.provider_id_required. The store intentionally does not guess or default to the first provider.","triggerScenarios":"Calling startProviderOAuth with providerId === undefined, or a string that is empty/whitespace after .trim() — e.g. startProviderOAuth(undefined), startProviderOAuth(\"\"), startProviderOAuth(\"   \").","commonSituations":"UI wiring bug where the selected provider binding is empty (unselected dropdown); a caller passing a variable that was never initialized; programmatic callers/tests invoking the action without arguments; form state cleared before submit.","solutions":["Pass a non-empty providerId to startProviderOAuth, resolved from the user's selection.","Fix the UI state so the provider selection is always set before the action is callable (disable the button until a provider is chosen).","Check for a mapping bug where the stored provider name is trimmed to empty.","In tests, pass an explicit providerId like 'anthropic' instead of relying on defaults."],"exampleFix":"// before\nawait startProviderOAuth(selectedProviderId); // selectedProviderId may be \"\"\n// after\nif (!selectedProviderId?.trim()) return;\nawait startProviderOAuth(selectedProviderId.trim());","handlingStrategy":"validation","validationCode":"const resolved = selectedProviderId?.trim();\nif (!resolved) {\n  showToast(\"Select a provider first.\");\n  return;\n}\nawait store.startProviderOAuth(resolved);","typeGuard":"function isNonEmptyString(v: unknown): v is string {\n  return typeof v === \"string\" && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await store.startProviderOAuth(providerId);\n} catch (e) {\n  if (e instanceof Error && /provider.?id.?required/i.test(e.message)) {\n    focusProviderSelector();\n  } else throw e;\n}","preventionTips":["Keep provider selection in typed state, not a possibly-empty free string.","Disable submit/start actions until a provider is chosen.","Trim and validate provider ids at the UI boundary before calling store actions.","In tests, always pass explicit provider ids."],"tags":["validation","arguments","provider-auth"],"backgroundTag":"missing-required-argument","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}