Skip to content

Creating tasks with import statements fail #490

@anwu

Description

@anwu

Steps to reproduce:
List the minimal actions needed to reproduce the behavior.

  1. Calling InfluxDBClient.TasksApi.create_task() with an import statement does not work.
  2. Similarly, creating a task directly using the API endpoint /api/v2/tasks with an import statement after the option task variable.
curl http://localhost:8086/api/v2/tasks \
  --header "Content-type: application/json" \
  --header "Authorization: Token INFLUX_TOKEN" \
  --data-binary @- << EOF
    {
    "orgID": "INFLUX_ORG_ID",
    "description": "IoT Center 30d environment average.",
    "flux": "option task = {name: \"iot-center-task-1\", every: 30m}\
            import \"http\"\
            from(bucket: \"iot_center\")\
              |> range(start: -30d)\
              |> filter(fn: (r) => r._measurement == \"environment\")\
              |> aggregateWindow(every: 1h, fn: mean)"
    }
EOF

This will return an error saying that the import statement is invalid.

HTTP response body: {"code":"invalid","message":"invalid options; Err: loc 3:1-3:7: invalid statement @3:1-3:7: import: loc 3:1-3:7: invalid statement @3:1-3:7: import"}

Expected behavior:
Expected the task to be created.

Actual behavior:
HTTP response from the server saying that the "import" statement is invalid.

HOWEVER, when the import statements are placed BEFORE the "option task ..." declaration, the API call works.
The API probably needs to be fixed. But I was told that to file a ticket here and that it will be fixed via the python client library.

Specifications:

  • Client Version: 1.31.1
  • InfluxDB Version: Influx Cloud
  • Platform: Ubuntu 20.04 on WSL

Additional Info:
https://influxcommunity.slack.com/archives/CH8RV8PK5/p1659743604599309

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions