Task Error: no execution context for tableFind to use

I am trying to create a simple task that will report some measurements back to my custom endpoint but getting error while trying to submit the task to my influxdb OSS 2.0. I have tested my flux code into “data explorer” and works fine but not when i am trying to submit it as a task. My code:

import “json”
import “http”

data = from(bucket: “metrics”)
|>range(start: -30d)
|>filter(fn: (r) => r._measurement == “temperature”)

lastReported = data
|>tableFind(fn: (key) => key._measurement == “temperature”)
|>getRecord(idx: 0)

j = json.encode(v: lastReported)
http.post(url: “https://myurl…”,
headers: {“Content-type”: “application/x-www-form-urlencoded”},
data: j)

Error Message:
Failed to update task: failed to update task: invalid options: error calling function “tableFind” @13:5-14:39: no execution context for tableFind to use

I have searched for the issue but it seems that there is nothing relative of it.
Thanks in advance!

@stevegtdbz what version of OSS 2.0 are you using? You’re likely hitting this issue, which (I believe) has been fixed in later patch releases: Unable to perform a tableFind within a Task · Issue #18922 · influxdata/influxdb · GitHub

Hi, i am using Version 2.0.4 (4e7a59b).

2.0.4 was released before the bug was fixed, I’d recommend upgrading to 2.0.6

Just upgraded, it works now. Thank you very much!

Hello @stevegtdbz,
I also recommend trying
|>tableFind(fn: (key) => true) if you’re only returning 1 table.