{"record":{"id":"f15325071eb9a6c4","repo":"n8n-io/n8n","slug":"authentication-failed-please-check-your-api-key-o","errorCode":null,"errorMessage":"Authentication failed. Please check your API key or token in the credentials","messagePattern":"Authentication failed\\. Please check your API key or token in the credentials","errorType":"exception","errorClass":"NodeApiError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.ts","lineNumber":373,"sourceCode":"\t\t\t\t\treturn { results: [] };\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\n\t\t\t\t\t// Check for connection errors\n\t\t\t\t\tif (errorMessage.includes('ECONNREFUSED') || errorMessage.includes('Failed to connect')) {\n\t\t\t\t\t\tthrow new NodeApiError(this.getNode(), {\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t'Cannot connect to ChromaDB. Please ensure ChromaDB is running and accessible at the configured URL.',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check for authentication errors\n\t\t\t\t\tif (\n\t\t\t\t\t\terrorMessage.includes('Unauthorized') ||\n\t\t\t\t\t\terrorMessage.includes('401') ||\n\t\t\t\t\t\terrorMessage.includes('403')\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new NodeApiError(this.getNode(), {\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t'Authentication failed. Please check your API key or token in the credentials',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new NodeApiError(this.getNode(), {\n\t\t\t\t\t\tmessage: `Failed to list ChromaDB collections: ${errorMessage}`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\tretrieveFields,\n\tloadFields: retrieveFields,\n\tinsertFields,\n\tsharedFields,\n\n\tasync getVectorStoreClient(context, _filter, embeddings, itemIndex) {","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.ts#L355-L391","documentation":"Thrown as a NodeApiError during the Chroma collection listSearch when the caught error message contains `Unauthorized`, `401`, or `403`. It signals that the request reached ChromaDB (or Chroma Cloud) but was rejected for credentials reasons. Detection is by string matching on the error message.","triggerScenarios":"Listing collections against Chroma Cloud with an expired or wrong API key; against a self-hosted ChromaDB fronted by an auth proxy returning 401/403; credentials typed into the wrong auth type (e.g. Cloud key used against a Self-Hosted connection).","commonSituations":"API key regenerated in Chroma Cloud but n8n credential not updated; token paste error (leading/trailing whitespace); Basic-auth header missing on a reverse-proxy that requires it; tenant/database mismatch on Cloud.","solutions":["Open the credential in n8n and re-paste the current Chroma Cloud API key (trim any whitespace).","Confirm the `Authentication` option matches the credential type (Cloud vs Self-Hosted).","For self-hosted behind auth, verify the proxy's required header is being sent and the token hasn't expired.","For Cloud, verify the tenant and database values are correct for the API key."],"exampleFix":"// before\nif (errorMessage.includes('Unauthorized') || errorMessage.includes('401') || errorMessage.includes('403')) {\n  throw new NodeApiError(this.getNode(), { message: 'Authentication failed...' });\n}\n\n// after: include the HTTP status when available so the user can distinguish 401 vs 403\nconst status = (error as { statusCode?: number }).statusCode;\nconst authHint = status === 401 || status === 403 || /Unauthorized|401|403/.test(errorMessage);\nif (authHint) {\n  throw new NodeApiError(this.getNode(), {\n    message: 'Authentication failed. Please check your API key or token in the credentials',\n    description: status ? `HTTP ${status} from ChromaDB` : undefined,\n  });\n}","handlingStrategy":"validation","validationCode":"// When saving the credential, do a listCollections probe to verify auth before the workflow runs.\nasync function verifyChromaAuth(client: ChromaClient): Promise<void> {\n  try {\n    await client.listCollections();\n  } catch (error) {\n    const msg = error instanceof Error ? error.message : String(error);\n    if (/Unauthorized|401|403/.test(msg)) {\n      throw new Error('Authentication failed. Please check your API key or token in the credentials');\n    }\n    throw error;\n  }\n}","typeGuard":"function isAuthError(error: unknown): boolean {\n  if (!(error instanceof Error)) return false;\n  const status = (error as { statusCode?: number }).statusCode;\n  return status === 401 || status === 403 || /Unauthorized|401|403/.test(error.message);\n}","tryCatchPattern":"try {\n  return await chromaClient.listCollections();\n} catch (error) {\n  if (isAuthError(error)) {\n    throw new NodeApiError(node, { message: 'Authentication failed. Please check your API key or token in the credentials' });\n  }\n  throw error;\n}","preventionTips":["Re-paste the API key whenever it is rotated in Chroma Cloud.","Trim whitespace when reading credentials from env vars.","Verify the Authentication mode (Cloud vs Self-Hosted) matches the credential type."],"tags":["chromadb","vector-store","authentication","credentials","node-api-error","langchain"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}