influxdata / influxdata/influxdb
`/api/v2/templates/apply` allows only one object in `remotes`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
`/api/v2/templates/apply` returns `duplicate name` validation errors and `unprocessable entity` status when I pass multiple objects in the `remotes` array.
__Steps to reproduce:__
List the minimal actions needed to reproduce the behavior.
1. In the request body, pass an array of `{"url": "TEMPLATE_URL"} objects with the `remotes` parameter--for example:
```sh
curl -v --request POST \
"${INFLUX_URL}/api/v2/templates/apply" \
--header "Authorization: Token ${INFLUX_ALL_ACCESS_TOKEN}" \
--data @- << EOF
{
"orgID": "$INFLUX_ORG_ID",
"dryRun": true,
"remotes": [
{
"url": "https://raw.githubusercontent.com/influxdata/community-templates/master/linux_system/linux_system.yml"
},
{
"url": "https://raw.githubusercontent.com/influxdata/community-templates/master/aws_lambda/lambda.yml"
}
]
}
EOF
```
__Expected behavior:__
Expect both templates to be applied, as implied by the spec: https://docs.influxdata.com/influxdb/v2.3/api/#operation/ApplyTemplate.
__Actual behavior:__
Responds with HTTP `422` status and the following errors:
```sh
"errors": [
{
"kind": "Variable",
"fields": [
"root",
"spec",
"name"
],
"idxs": [
17,
null,
null
],
"reason": "duplicate name: lucid-kepler-8bf001"
}
],
"code": "unprocessable entity",
"message": "unprocessable entity"
```
If I pass each URL in a separate request - only one object in `remotes: []`, then the templates apply successfully.
__Environment info:__
* System info: Darwin 21.6.0 x86_64
* InfluxDB version: InfluxDB 2.3.0 (git: 090f681737) build_date: 2022-06-16T18:48:06Z
* Other relevant environment details: Container runtime, disk info, etc
__Config:__
Copy any non-default config values here or attach the full config as a gist or file.
__Logs:__
Include snippet of errors in log.
__Performance:__
Generate profiles with the following commands for bugs related to performance, locking, out of memory (OOM), etc.
```sh
# Commands should be run when the bug is actively happening.
# Note: This command will run for ~30 seconds.
curl -o profiles.tar.gz "http://localhost:8086/debug/pprof/all?cpu=30s"
iostat -xd 1 30 > iostat.txt
# Attach the `profiles.tar.gz` and `iostat.txt` output files.
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the request against `/api/v2/templates/apply` with the two URLs shown and compare the behavior with the linked ApplyTemplate specification. Done means the request successfully applies both remote templates without a duplicate-name validation error or HTTP 422 response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100