{"record":{"id":"fc191d38497bf7e9","repo":"toeverything/AFFiNE","slug":"unsupported-byok-provider","errorCode":null,"errorMessage":"Unsupported BYOK provider.","messagePattern":"Unsupported BYOK provider\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/apps/electron/src/main/byok-storage/handlers.ts","lineNumber":162,"sourceCode":"        isRecord(model) &&\n        typeof model.modelId === 'string' &&\n        model.modelId.trim().length > 0 &&\n        model.modelId.length <= 512 &&\n        typeof model.enabled === 'boolean' &&\n        Array.isArray(model.capabilities) &&\n        model.capabilities.length > 0 &&\n        model.capabilities.every(isValidCapability)\n    )\n  );\n}\n\nfunction normalizeKey(\n  key: WorkspaceByokKeyInput,\n  existing?: WorkspaceByokKey,\n  defaultSortOrder = 0\n): WorkspaceByokKey {\n  if (!allowedProviders.has(key.provider)) {\n    throw new Error('Unsupported BYOK provider.');\n  }\n  const credential = key.credential ?? existing?.credential;\n  const definition = key.definition ?? existing?.definition;\n  if (\n    definition?.endpoint.kind === 'openai_compatible' &&\n    key.provider !== 'openai'\n  ) {\n    throw new Error('OpenAI-compatible endpoints require OpenAI provider.');\n  }\n  if (!key.id || !key.name || !credential || !isValidDefinition(definition)) {\n    throw new Error('Invalid BYOK key.');\n  }\n  return {\n    id: key.id,\n    provider: key.provider,\n    name: key.name,\n    description: hasOwnField(key, 'description')\n      ? (key.description ?? null)","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/apps/electron/src/main/byok-storage/handlers.ts#L144-L180","documentation":"normalizeKey validates the key's provider against the allowedProviders set; a provider outside the allowlist (e.g. misspelled or unsupported) is rejected with this Error. Called by encryptKey, decryptKey, and nextKey.","triggerScenarios":"Thrown at packages/frontend/apps/electron/src/main/byok-storage/handlers.ts:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose one of the supported BYOK providers listed in the settings UI.","Fix the provider identifier passed from the client to match a supported value.","Update the app if the provider was added in a newer version."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}