influxdata / influxdata/influxdb-java

Incorrect URLs formed if base URL contains a path segment

Open
#268 4 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.2k
Forks
469
PR merge metrics
No merged PRs in 30d

Description

(Tested with influxdb-java version 2.5)

We're using a HTTPS reverse proxy in front our influxdb instance.

The external URLs is https://scala-ci.typesafe.com/influx/write.

The URL actually generated by influxdb-java is https://scala-ci.typesafe.com/write.

I believe that changing @POST("/write") to @POST("write"), etc, in InfluxDBService.java would fix this, but haven't verified.

A workaround is to add an interceptor to fixup the URL.

        OkHttpClient.Builder client = new OkHttpClient.Builder();
        client.addNetworkInterceptor(chain -> {
            HttpUrl.Builder fixedUrl = chain.request().url().newBuilder().encodedPath("/influx/" + chain.request().url().encodedPath().replaceFirst("/influxdb", ""));
            return chain.proceed(chain.request().newBuilder().url(fixedUrl.build()).build());
        });
        InfluxDB influxDB = InfluxDBFactory.connect("https://scala-ci.typesafe.com/influx/", user, password, client);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading InfluxDBService.java and tracing how its endpoint annotations combine with a base URL containing /influx. Reproduce the reported request against https://scala-ci.typesafe.com/influx/ and verify that generated URLs preserve the base path segment without requiring the interceptor workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.