influxdata / influxdata/influxdb-client-java

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

未关闭
#565 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Java
星标
477
派生
129
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 TasksApiImpl.java:501 开始,其中 TaskApi#getRuns 出现在堆栈跟踪中,并检查 InfluxDbClientTest.java:459 中相关的调用。复现 afterTime 和 beforeTime 恰好处于同一分钟的情况,然后添加或更新回归测试,以展示请求在没有 BadRequestException 的情况下返回 runs。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
api, backend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。