{"record":{"id":"5e9d5ebc663b9eee","repo":"danny-avila/LibreChat","slug":"no-user-key-5e9d5e","errorCode":"no_user_key","errorMessage":"{\"type\":\"no_user_key\"}","messagePattern":"\\{\"type\":\"no_user_key\"\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/server/services/Endpoints/azureAssistants/initialize.js","lineNumber":146,"sourceCode":"\n      const groupName = modelGroupMap[modelName].group;\n      clientOptions.addParams = azureConfig.groupMap[groupName].addParams;\n      clientOptions.dropParams = azureConfig.groupMap[groupName].dropParams;\n\n      clientOptions.reverseProxyUrl = baseURL ?? clientOptions.reverseProxyUrl;\n      clientOptions.headers = opts.defaultHeaders;\n      clientOptions.azure = !serverless && azureOptions;\n      if (serverless === true) {\n        clientOptions.defaultQuery = azureOptions.azureOpenAIApiVersion\n          ? { 'api-version': azureOptions.azureOpenAIApiVersion }\n          : undefined;\n        clientOptions.headers['api-key'] = apiKey;\n      }\n    }\n  }\n\n  if (userProvidesKey & !apiKey) {\n    throw new Error(\n      JSON.stringify({\n        type: ErrorTypes.NO_USER_KEY,\n      }),\n    );\n  }\n\n  if (!apiKey) {\n    throw new Error('Assistants API key not provided. Please provide it again.');\n  }\n\n  if (baseURL) {\n    opts.baseURL = baseURL;\n  }\n\n  const proxyDispatcher = getProxyDispatcher(PROXY);\n  if (proxyDispatcher) {\n    opts.fetchOptions = {\n      dispatcher: proxyDispatcher,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Endpoints/azureAssistants/initialize.js#L128-L164","documentation":"Azure Assistants variant of the no_user_key error. Thrown when the user is expected to supply their own Azure OpenAI key (userProvidesKey) but none was provided. Emits a JSON-stringified payload with type NO_USER_KEY for client-side detection. Uses the same single-'&' bitwise pattern as the non-Azure path.","triggerScenarios":"An Azure Assistants endpoint configured for user-provided keys receives a request without an apiKey in userValues during initialization.","commonSituations":"User's Azure key cleared from storage; frontend submitted without the key; endpoint switched to user-provided-key mode without updating stored credentials.","solutions":["Supply the Azure OpenAI key via userValues.apiKey and retry.","If a server-managed key is preferred, configure the Azure credentials at the server level.","Re-prompt the user to enter their Azure key through the no_user_key UI flow.","Re-enter the stored credential to rule out corruption."],"exampleFix":"// before\nif (userProvidesKey & !apiKey) {\n// after\nif (userProvidesKey && !apiKey) {","handlingStrategy":"validation","validationCode":"if (userProvidesKey && !userValues.apiKey) {\n  return res.status(400).json({ error: 'An Azure OpenAI key is required for this endpoint' });\n}","typeGuard":"function hasAzureUserKey(userProvidesKey, userValues) {\n  return !userProvidesKey || typeof userValues?.apiKey === 'string' && userValues.apiKey.length > 0;\n}","tryCatchPattern":"try { await initializeAzure(req, res, version); }\ncatch (e) { if (e.message.includes('NO_USER_KEY')) return res.status(401).json({ code: 'no_user_key' }); throw e; }","preventionTips":["Validate the Azure key client-side when user-provided keys are required.","Re-prompt on NO_USER_KEY; do not retry silently.","Use '&&' rather than '&' in the guard condition."],"tags":["azure","assistants","api-key","authentication"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}