influxdata / influxdata/influxdb-client-java

Problem query runs with beforeTime and afterTime, with exact time in minutes

Open
#565 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
477
Forks
129
PR merge metrics
No merged PRs in 30d

Description

When execute TaskApi#getRuns with beforeTime and afterTime on exact time in minutes, it throws BadRequestException and can not get result.

__Steps to reproduce:__
List the minimal actions needed to reproduce the behavior.

1. Set afterTime and beforeTime, with exact time

```
OffsetDateTime afterTime = OffsetDateTime.parse("2023-05-20T10:15:00+09:00");
OffsetDateTime beforeTime = OffsetDateTime.parse("2023-05-20T11:15:00+09:00");
Integer limit = 100;

InfluxDBClient client = getClient();
client.getTasksApi().getRuns(task.getId(), afterTime, beforeTime, limit);
```

__Expected behavior:__
Returns the runs without error, executed between afterTime and beforeTime.

__Actual behavior:__
Got BadGrammerExeception.

The reason is, TaskApi#getRuns ( and InfluxDB itself) expects afterTime and beforeTime as strictly rfc3339 format, but parameter value type is [OffsetDateTime](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) which is ISO-8601 format. Therefore, it formats timestamp as ISO-8601 format omitting some part when the timestamp is exact minute time.

```
HTTP status code: 400; Message: failed to decode request: parsing time "2023-05-20T10:15+09:00" as "2006-01-02T15:04:05Z07:00": cannot parse "+09:00" as ":"
com.influxdb.exceptions.BadRequestException: HTTP status code: 400; Message: failed to decode request: parsing time "2023-05-20T10:15+09:00" as "2006-01-02T15:04:05Z07:00": cannot parse "+09:00" as ":"
at com.influxdb.internal.AbstractRestClient.responseToError(AbstractRestClient.java:113)
at com.influxdb.internal.AbstractRestClient.execute(AbstractRestClient.java:84)
at com.influxdb.client.internal.TasksApiImpl.getRuns(TasksApiImpl.java:501)
at jp.co.iim.collie.ui.common.repository.influxdb.InfluxDbClientTest.taskTest(InfluxDbClientTest.java:459)
```

__Specifications:__
- Client Version: 6.7.0
- InfluxDB Version: InfluxDB 2.1.1
- JDK Version: OpenJDK 1.8.0_281
- Platform: CentOS 7

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 at TasksApiImpl.java:501, where TaskApi#getRuns appears in the stack trace, and inspect the related InfluxDbClientTest.java:459 call. Reproduce the exact-minute afterTime and beforeTime case, then add or update a regression test showing that the request returns runs without a BadRequestException.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.