{"record":{"id":"aa2ee7a9ddb8f3a3","repo":"chroma-core/chroma","slug":"auth-provider-not-specified","errorCode":null,"errorMessage":"Auth provider not specified","messagePattern":"Auth provider not specified","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/auth.ts","lineNumber":88,"sourceCode":"    }\n\n    const headerKey: string = tokenHeaderTypeToHeaderKey(headerType);\n    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":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/auth.ts#L70-L106","documentation":"authOptionsToAuthProvider (auth.ts), called from the ChromaClient and AdminClient constructors whenever an auth option object is supplied, requires auth.provider to be set. If you pass auth: { credentials: ... } without a provider, there is no way to choose between BasicAuthClientProvider and TokenAuthClientProvider, so the constructor throws immediately. Supported values are 'basic' and 'token'.","triggerScenarios":"new ChromaClient({ auth: { credentials: 'admin:admin' } }) (provider omitted); building the auth object conditionally and the provider branch never executes; passing auth: {}.","commonSituations":"Upgrading code to the auth options API and only wiring credentials; config templates where provider is commented out; assuming the client infers the provider type from the credential format.","solutions":["Add provider: 'basic' or provider: 'token' to the auth object.","Type the parameter as AuthOptions (or a literal type) so TypeScript flags the missing field.","Validate the auth object once at startup and fail fast with a clear message."],"exampleFix":"// before\nconst client = new ChromaClient({ auth: { credentials: 'admin:admin' } });\n\n// after\nconst client = new ChromaClient({\n  auth: { provider: 'basic', credentials: 'admin:admin' },\n});","handlingStrategy":"type-guard","validationCode":"if (!auth || auth.provider === undefined) {\n  throw new Error('Chroma auth option requires provider: \"basic\" or \"token\"');\n}","typeGuard":"function isCompleteAuthOptions(\n  auth: AuthOptions,\n): auth is AuthOptions & { provider: 'basic' | 'token' } {\n  return (\n    (auth.provider === 'basic' || auth.provider === 'token') &&\n    auth.credentials !== undefined\n  );\n}","tryCatchPattern":"try {\n  new ChromaClient({ path, auth });\n} catch (e) {\n  if (e instanceof Error && e.message === 'Auth provider not specified') {\n    // add provider: 'basic' | 'token' to the auth object\n  }\n  throw e;\n}","preventionTips":["Centralize client construction in one factory so the auth object shape is validated once.","Type auth config as AuthOptions and default provider explicitly in your config layer.","Add startup validation of all required config fields (provider, credentials) before creating clients."],"tags":["auth","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"}