influxdata / influxdata/influxdb
HTTP API timestamps don't evaluate correctly
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
__Steps to reproduce:__
List the minimal actions needed to reproduce the behavior.
1. Create a row, eg `meas,tag1=1,tag2=2 value=1 1665946265`
2. Send a POST request via Python `requests` module:
```
rsp = requests.post(
"https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/write",
params={"org": org, "bucket": bucket, "precision": "s"},
headers=headers,
data=data,
)
```
3. Look at raw data for bucket in UI
__Expected behavior:__
I see my data point submitted with the correct time.
__Actual behavior:__
No matter what timestamp I pass in, it evaluates to `2022-12-30T00:52:50.000Z`. I'm submitting 4 points with an old timestamp and 4 with a more recent timestamp, and only 4 show up when I look at raw data.
__Environment info:__
* System info: Run `uname -srm` and copy the output here: `Darwin 21.2.0 arm64`
Code:
```
now = pytz.utc.localize(datetime.utcnow())
headers = {"Authorization": f"Token {token}"}
params = {"org": influx_org, "bucket": f"org_{org_id}", "precision": "s"}
new_ts = int(now.timestamp())
old_ts = int((now - timedelta(days=8)).timestamp())
data = f"""\
advertising,campaign=campaign,... impressions=1 {old_ts}
advertising,campaign=... impressions=1 {old_ts}
advertising,campaign=... impressions=1 {old_ts}
advertising,campaign=... impressions=1 {old_ts}
advertising,campaign=... impressions=1 {new_ts}
advertising,campaign=... impressions=1 {new_ts}
advertising,campaign=... impressions=1 {new_ts}
advertising,campaign=... impressions=1 {new_ts}
"""
rsp = requests.post(
"https://us-east-1-1.aws.cloud2.influxdata.com/api/v2/write",
params=params,
headers=headers,
data=data,
)
```
This returns with a 204.
I've tried different newline conventions with no luck. I've also tried converting `data` into a list and submitting each data point individually, and this yielded the same results. So, I don't think it's a newline issue.
Contributor guide
Research direction
Start by reproducing the POST to /api/v2/write with Python requests, precision=s, and the old and new timestamps shown in the report; inspect the resulting raw bucket data. Trace the HTTP write path and timestamp handling, then verify that all eight points retain their submitted times and that the endpoint still returns 204.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100