influxdata / influxdata/influxdb

http.post does not work in task

Open
#20,507 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Steps to reproduce:__
I used the following flux script to delete data when some criteria meet, while in curl or query, it works fine. But when i put it in task, then it fails to work.
```
import "http"
import "json"
from(bucket: "systembucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "test")
|> aggregateWindow(every: 24h, fn: last, createEmpty: false)
|> limit(n:1)
|> map(fn: (r) =>
({r with jsonStr: string(v: json.encode(v: {"start": "2021-01-11T22:00:00Z", "stop": "2021-01-13T00:00:00Z", "predicate": "_measurement=\"cpu\""}))}))
|> map(fn: (r) =>
({r with status_code: http.post(url: "http://localhost:8086/api/v2/delete?org=testorg&bucket=testbucket", headers: {"Content-Type": "application/json", Authorization: "Token "}, data: bytes(v: r.jsonStr))}))
```

__Expected behavior:__
Data should be deleted as post request

__Actual behavior:__
Nothing happened. No error in log.

__Environment info:__
Influxdb v2.0.3

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied Flux script as a task on InfluxDB v2.0.3, comparing it with the working curl or query behavior. Investigate the task execution path for http.post and determine how the request and any errors are handled. Done means the POST executes from a task and the expected data deletion occurs with an observable failure if it cannot run.

Written by the indexing model from the issue text.

Assessment

Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.