Repository navigation
fix: apply host when both withHost and withOkHttpClient are set - #231
Open
kksingh000 wants to merge 1 commit into
Open
kksingh000 wants to merge 1 commit into
kksingh000 wants to merge 1 commit into
Conversation
Pinecone.Builder.build() only applied withHost(...) inside the else branch of `if (customOkHttpClient != null)`, so an explicitly configured host was silently dropped whenever a custom OkHttpClient was also supplied — requests fell back to the default api.pinecone.io instead. Moves the host-setting logic (config.setHost / apiClient.setBasePath) out of that else branch so it always runs when a host is configured, regardless of which OkHttpClient path was taken. This matches the root-cause and fix already confirmed by a maintainer in the issue thread; a prior attempt at this exact fix (PR pinecone-io#210, via a Cursor background agent) was opened in January 2026 but closed unmerged in June 2026 without landing. Fixes pinecone-io#192 Testing: - Added PineconeWithHostAndCustomOkHttpClientUsesHost to PineconeBuilderTest, which builds a client with both withHost(...) and withOkHttpClient(...) and asserts the outgoing request's host and port match the configured host. - Verified empirically: with the fix reverted (source reset to the current main HEAD) the new test fails exactly as the issue describes (expected "my-custom-host" but was "api.pinecone.io"); with the fix restored it passes. - Full suite: `./gradlew clean build -x integrationTest` — BUILD SUCCESSFUL, 91/91 unit tests pass (90 pre-existing + 1 new), JDK 21. - integrationTest not run (needs PINECONE_API_KEY and live infrastructure); unaffected by this change since it only touches Builder.build()'s client construction path. This change, including the regression test and this PR description, was written with AI assistance (Claude).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Pinecone.Builder.build()only applieswithHost(...)inside theelsebranch ofif (customOkHttpClient != null):So an explicitly configured host is silently dropped whenever a custom
OkHttpClientis also supplied, and requests fall back to the defaultapi.pinecone.ioinstead of the intended host. This matches the root cause already confirmed by a maintainer in the issue thread.A prior attempt at this exact fix (#210, opened via a Cursor background agent) was opened in January 2026 but closed unmerged in June 2026 without landing.
Solution
Moves the host-setting logic (
config.setHost/apiClient.setBasePath) out of theelsebranch so it always runs when a host is configured, regardless of whichOkHttpClientpath was taken above it.proxyConfigandcustomOkHttpClientcan't both be set (the builder already throwsPineconeConfigurationExceptionearlier if they are), so this doesn't change behavior for that combination.Fixes #192
Type of Change
Test Plan
PineconeWithHostAndCustomOkHttpClientUsesHosttoPineconeBuilderTest, which builds a client with bothwithHost(...)andwithOkHttpClient(...)and asserts the outgoing request's host and port match the configured host.mainHEAD, test kept as-is), the new test fails exactly as the issue describes —expected: <my-custom-host> but was: <api.pinecone.io>. With the fix restored, it passes../gradlew clean build -x integrationTest— BUILD SUCCESSFUL, 91/91 unit tests pass (90 pre-existing + 1 new), JDK 21.integrationTestnot run (needsPINECONE_API_KEYand live infrastructure); this change only touchesBuilder.build()'s client-construction path so it shouldn't be affected.Disclosure: this change, including the regression test and this PR description, was written with AI assistance (Claude).
Note
Low Risk
Small, localized change to client construction with a regression test; behavior only changes for the previously broken host+custom-client combination.
Overview
Fixes a bug where
withHost(...)was ignored wheneverwithOkHttpClient(...)was also used onPinecone.Builder. Host setup (config.setHost/apiClient.setBasePath) lived only in the non-custom-client branch, so control-plane calls defaulted toapi.pinecone.ioinstead of the configured base URL.The PR moves host application after the OkHttpClient branch so it always runs when a host is set, for both default and custom clients. A regression test builds a client with both options and asserts the outgoing request uses the configured host and port (issue #192).
Reviewed by Cursor Bugbot for commit 9007b34. Bugbot is set up for automated code reviews on this repo. Configure here.