Skip to content

Conversation

@philipithomas
Copy link
Contributor

Philip here from the Chroma team.

This SDK currently authenticates via a bearer token.

However, Chroma uses the x-chroma-token header instead of bearer, leading all authenticated requests with this SDK to fail with a 401 error. (Details in the Chroma OpenAPI spec: https://api.trychroma.com/docs/ )

I've patched the authentication method in this PR.

Signed-off-by: Philip I. Thomas <[email protected]>
@ilayaperumalg ilayaperumalg added this to the 1.1.0.M4 milestone Oct 8, 2025
@ilayaperumalg ilayaperumalg added the bug Something isn't working label Oct 8, 2025
@ilayaperumalg
Copy link
Member

@philipithomas Thanks for the PR!

@Kehrlann Could you review the changes please? Thanks!

@philipithomas
Copy link
Contributor Author

@Kehrlann Happy to help set up a free Chroma Cloud org for E2E testing, whether manual or automated - my email is philip at trychroma.com.

Copy link
Contributor

@Kehrlann Kehrlann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @philipithomas ! The fix seems correct.

[question] I'm a bit confused as to why the TokenSecuredChromaWhereIT does not fail with the current setup. Can you try it on your machine, and try to reproduce?
Is it because it's an outdated Chroma image?
It'd be good to have this correctly covered by tests.

[suggestion, non-blocking] One nice-to-have, good opportunity for a small refactoring. Instead of capturing the token in ChromApi#withToken, we do something similar to ChromaApi#withBasicAuthCredentials, something like:

public ChromaApi withKeyToken(String keyToken) {
	this.restClient = this.restClient.mutate()
			.defaultHeader(X_CHROMA_TOKEN, keyToken)
			.build();
	return this;
}

And we remove both the keyToken field and the httpHeader method.

private void httpHeaders(HttpHeaders headers) {
if (StringUtils.hasText(this.keyToken)) {
headers.setBearerAuth(this.keyToken);
headers.set("x-chroma-token", this.keyToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider putting x-chroma-token in a static field.

@ilayaperumalg
Copy link
Member

@philipithomas Could you check the latest review comments? Thanks

@ilayaperumalg ilayaperumalg modified the milestones: 1.1.0.M4, 1.1.0.RC1 Oct 31, 2025
@philipithomas
Copy link
Contributor Author

[question] I'm a bit confused as to why the TokenSecuredChromaWhereIT does not fail with the current setup. Can you try > it on your machine, and try to reproduce?
Is it because it's an outdated Chroma image?
It'd be good to have this correctly covered by tests.

I believe that the server does not support that environment variable, so it's unauthenticated and responding to the request.

@philipithomas
Copy link
Contributor Author

@ilayaperumalg Just patched it - ready for re-review

@Kehrlann
Copy link
Contributor

Kehrlann commented Nov 4, 2025

I believe that the server does not support that environment variable, so it's unauthenticated and responding to the request.

Got it, too bad then.

@ilayaperumalg
Copy link
Member

@philipithomas Thanks for the PR and @Kehrlann thanks for the review. Rebased, squashed and merged as 0abfedf

@Jayaprabahar
Copy link

Jayaprabahar commented Nov 7, 2025

Hi @philipithomas ,
As discussed, It is tested and working.

Hope it will be soon pushed into maven repo as well.

Thanks

@ilayaperumalg
Copy link
Member

@Jayaprabahar Thanks for testing and update! This will be part of 1.1.0-RC1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working chromadb

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants