chroma-core/chroma · error · Error

Auth provider not specified

Error message

Auth provider not specified

What it means

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'.

Source

Thrown at clients/js/packages/chromadb-core/src/auth.ts:88

    }

    const headerKey: string = tokenHeaderTypeToHeaderKey(headerType);
    const headerVal =
      headerType === "AUTHORIZATION" ? `Bearer ${creds}` : creds;
    this.credentials = {};
    this.credentials[headerKey] = headerVal;
  }

  authenticate(): AuthHeaders {
    return this.credentials;
  }
}

export const authOptionsToAuthProvider = (
  auth: AuthOptions,
): ClientAuthProvider => {
  if (auth.provider === undefined) {
    throw new Error("Auth provider not specified");
  }
  if (auth.credentials === undefined) {
    throw new Error("Auth credentials not specified");
  }
  switch (auth.provider) {
    case "basic":
      return new BasicAuthClientProvider(auth.credentials);
    case "token":
      return new TokenAuthClientProvider(
        auth.credentials,
        auth.tokenHeaderType,
      );
      break;
    default:
      throw new Error("Invalid auth provider");
  }
};

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Add provider: 'basic' or provider: 'token' to the auth object.
  2. Type the parameter as AuthOptions (or a literal type) so TypeScript flags the missing field.
  3. Validate the auth object once at startup and fail fast with a clear message.

Example fix

// before
const client = new ChromaClient({ auth: { credentials: 'admin:admin' } });

// after
const client = new ChromaClient({
  auth: { provider: 'basic', credentials: 'admin:admin' },
});
Defensive patterns

Strategy: type-guard

Validate before calling

if (!auth || auth.provider === undefined) {
  throw new Error('Chroma auth option requires provider: "basic" or "token"');
}

Type guard

function isCompleteAuthOptions(
  auth: AuthOptions,
): auth is AuthOptions & { provider: 'basic' | 'token' } {
  return (
    (auth.provider === 'basic' || auth.provider === 'token') &&
    auth.credentials !== undefined
  );
}

Try / catch

try {
  new ChromaClient({ path, auth });
} catch (e) {
  if (e instanceof Error && e.message === 'Auth provider not specified') {
    // add provider: 'basic' | 'token' to the auth object
  }
  throw e;
}

Prevention

When it happens

Trigger: new ChromaClient({ auth: { credentials: 'admin:admin' } }) (provider omitted); building the auth object conditionally and the provider branch never executes; passing auth: {}.

Common situations: 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.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/aa2ee7a9ddb8f3a3. Report an issue: GitHub.