{"record":{"id":"3391ef5a56c5df1a","repo":"chroma-core/chroma","slug":"auth-credentials-not-specified","errorCode":null,"errorMessage":"Auth credentials not specified","messagePattern":"Auth credentials not specified","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/auth.ts","lineNumber":91,"sourceCode":"    const headerVal =\n      headerType === \"AUTHORIZATION\" ? `Bearer ${creds}` : creds;\n    this.credentials = {};\n    this.credentials[headerKey] = headerVal;\n  }\n\n  authenticate(): AuthHeaders {\n    return this.credentials;\n  }\n}\n\nexport const authOptionsToAuthProvider = (\n  auth: AuthOptions,\n): ClientAuthProvider => {\n  if (auth.provider === undefined) {\n    throw new Error(\"Auth provider not specified\");\n  }\n  if (auth.credentials === undefined) {\n    throw new Error(\"Auth credentials not specified\");\n  }\n  switch (auth.provider) {\n    case \"basic\":\n      return new BasicAuthClientProvider(auth.credentials);\n    case \"token\":\n      return new TokenAuthClientProvider(\n        auth.credentials,\n        auth.tokenHeaderType,\n      );\n      break;\n    default:\n      throw new Error(\"Invalid auth provider\");\n  }\n};\n","sourceCodeStart":73,"sourceCodeEnd":106,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/auth.ts#L73-L106","documentation":"authOptionsToAuthProvider throws this Error when the auth options given to new ChromaClient({ auth }) (or AdminClient) include a provider but leave credentials undefined. Note this check does NOT fall back to CHROMA_CLIENT_AUTH_CREDENTIALS itself - on the public client path you must set auth.credentials explicitly, even if the env var is set; the env-var fallback only happens inside the provider classes after this check passes.","triggerScenarios":"new ChromaClient({ auth: { provider: 'basic' } }) with no credentials; auth: { provider: 'token', credentials: process.env.CHROMA_TOKEN } when CHROMA_TOKEN is unset (reads as undefined); spreading an options object whose credentials key is absent.","commonSituations":"Assuming the client reads CHROMA_CLIENT_AUTH_CREDENTIALS automatically when auth options are provided; env var present in one environment but not another; typo in the credentials key inside a config object.","solutions":["Pass the credential explicitly: auth: { provider: 'basic', credentials: 'admin:admin' }.","Or feed the env var through: auth: { provider: 'token', credentials: process.env.CHROMA_CLIENT_AUTH_CREDENTIALS } (making sure the var is actually set before construction).","If you only rely on the env var, omit the whole auth option so the provider fallback path applies, or guard at startup."],"exampleFix":"// before\nconst client = new ChromaClient({ auth: { provider: 'token' } });\n\n// after\nconst client = new ChromaClient({\n  auth: {\n    provider: 'token',\n    credentials: process.env.CHROMA_CLIENT_AUTH_CREDENTIALS!,\n  },\n});","handlingStrategy":"validation","validationCode":"const credentials = process.env.CHROMA_CLIENT_AUTH_CREDENTIALS;\nif (!credentials) {\n  throw new Error('Set CHROMA_CLIENT_AUTH_CREDENTIALS before creating an authenticated ChromaClient');\n}\nconst client = new ChromaClient({ auth: { provider: 'basic', credentials } });","typeGuard":null,"tryCatchPattern":"try {\n  new ChromaClient({ auth });\n} catch (e) {\n  if (e instanceof Error && e.message === 'Auth credentials not specified') {\n    // auth.credentials must be set explicitly even when the env var exists\n  }\n  throw e;\n}","preventionTips":["Do not assume authOptionsToAuthProvider reads the env var - pass auth.credentials explicitly.","Validate credentials presence in your config loader and fail fast with a clear message.","Cover auth setup with a startup health check against the server."],"tags":["auth","credentials","configuration","client-construction","validation"],"backgroundTag":"missing-auth-config","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}