Skip to content

[Bug] There is no way to specify host and customOkHttpClient #192

@rterzman

Description

@rterzman

🐞 Describe the bug

You can specify host and customOkHttpClient when initializing Pinecone.Builder, but the host parameter is ignored if customOkHttpClient is provided. The condition in the code bypasses host handling:

if (customOkHttpClient != null) {
    apiClient = new ApiClient(customOkHttpClient);
} else {
    apiClient = new ApiClient(buildOkHttpClient(proxyConfig));
    if (host != null && !host.isEmpty()) {
        config.setHost(host);
        apiClient.setBasePath(host);
    }
}

This leads to host being unused when a custom client is passed, even if it was explicitly set.


📋 Error information

2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - --> POST https://api.pinecone.io/indexes
2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - Content-Length: 200
2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - Accept: application/json
2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - Api-Key: pclocal
2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - Content-Type: application/json
2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - User-Agent: lang=java; pineconeClientVersion=v5.1.0
2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - X-Pinecone-Api-Version: 2025-04
2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - 
2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - {"name":"integration-controller-test-index","dimension":2,"metric":"cosine","deletion_protection":"disabled","tags":{},"spec":{"serverless":{"cloud":"aws","region":"us-east-1"}},"vector_type":"dense"}
2025-06-25 21:40:14 INFO  okhttp3.OkHttpClient - --> END POST (200-byte body)
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - <-- 401 https://api.pinecone.io/indexes (681ms)
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - x-pinecone-api-version: 2025-04
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - x-cloud-trace-context: f4dc3225bc359c652619d4076f17a394
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - date: Wed, 25 Jun 2025 19:40:15 GMT
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - content-type: text/html
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - server: Google Frontend
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - content-length: 15
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - via: 1.1 google
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - 
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - Invalid API Key
2025-06-25 21:40:15 INFO  okhttp3.OkHttpClient - <-- END HTTP (15-byte body)

🧪 Steps to reproduce the issue locally

new Pinecone.Builder("API-KEY")
    .withHost("http://localhost:8080")
    .withOkHttpClient(new OkHttpClient.Builder()
        .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
        .build())
    .withTlsEnabled(false)
    .build();

🧭 Expected behavior

If host is specified, it should be respected regardless of whether a custom OkHttpClient is used.


💻 Environment

  • OS Version: macOS
  • Java Version: 21
  • Pinecone Client Version: v5.1.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingstatus:needs-triageAn issue that needs to be triaged by the Pinecone team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions