influxdata / influxdata/influxdb

Creating a slack alert through API has issues with interpolating strings

Open
#20,119 0 comments 0 reactions 0 assignees View on GitHub
area/2.x
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

Using this code in the explorer works but if creating a task through the API I get

```

[src/resetter.rs:61] &res.into_json().unwrap() = Object({
"code": String(
"invalid",
),
"message": String(
"failed to decode request: invalid character \'$\' after object key:value pair",
),
})

```

code:
```

import "slack"
import "influxdata/influxdb/monitor"

check = {
_check_id: "0000000000000001", // 16 characters, alphanumeric
_check_name: "Failed Tasks Check", // string
_type: "custom", // can also use "threashold" or "deadman"
tags: {},
}

url = "https://hooks.slack.com/services/adsadsaddsad"

from(bucket: "_tasks")
|> filter(fn: (r) => r["_measurement"] == "runs")
|> filter(fn: (r) => r["_field"] == "requestedAt")

|> pivot(
rowKey:["_time"],
columnKey: ["_field"],
valueColumn: "_value"
)

|> monitor.check(
crit: (r) => r.status == "success",
messageFn: (r) => "message",
data: check
)

|> map(fn: (r) => ({ status: slack.message(
url: url,
channel: "#test",
text: "\"${r.status}\" .",
color: "good"
)}))
|> yield(name: "mean")
```

Contributor guide

Open the contributing guide

Research direction

Start with the API task-creation path and src/resetter.rs around line 61, then compare how the same Flux is handled in the explorer. Reproduce the request with the interpolated Slack message and trace the decoding error. Done means the API accepts and correctly processes the task without the invalid '$' character error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, databases, observability-sre
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.