Panic error on task with date


when I try to add the task

import “date”
option task = { name: “test”, every: 1h, offset: 0h, concurrency: 1, retry: 3}
from(bucket: “b1”) |> range(start: date.truncate(t: -1mo, unit: 1mo)) |> to(bucket: “b2”)

I get the following error:

Error: A panic has occurred: /api/v2/tasks: interface conversion: interface {} is nil, not execute.ExecutionDependencies.

What am I doing wrong? If I use date.truncate(t: now(), unit: 1mo) instead of date.truncate(t: -1mo, unit: 1mo), the task gets accepted.

I’m using Influxdb 2.0.2 and I use the command

influx task create --org my-org -

to create the task.

Thank you in advance for your help!

Hello @Milo,
I think you have to pass a timestamp not a duration (-1mo) into the truncate function.
Try using subduration() to generate the timestamp first in a variable and then passing in the variable.

Hello Anaisdg,

thanks a lot for your suggestion, it worked!