influxdata / influxdata/influxdb

Enhanced errors from API on validation failures

Open
#16,727 0 comments 0 reactions 0 assignees View on GitHub
kind/feature-request team/ui team/user-tools
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Proposal:__
I would like to have errors that I can use to provide enhanced feedback in a programmatic way.

__Current behavior:__
Early exits (only ever 1 error). If there are multiple validation failures, then you will get first one encountered returned but none of the others.

__Desired behavior:__
I'll draw it out with an example, using a POST to `/api/v2/buckets` with a request body that fails to pass validation:

req body

```json
{
"name": "_reservedName",
"retentionRules": [
{
"type": "expire",
"everySeconds": -1,
}
]
}
```

This would fail both the name validation (can't have `_` prefix in bucket names, rserved for system buckets), and fails the retentionRules with the duration being less than 1 second.

I'd like to have a reply something akin too:

```json
{
"code": "unprocessable entity",
"errors": [
{
"field": "name",
"reason": "name must not be prefixed with \"_\""
},
{
"field": "retentionRules",
"reason": "expiration seconds must be greater than or equal to one second"
}
]
}
```

Something that I can use to inform the user and or my system in a programattic way.

__Alternatives considered:__
Adding `;` delimited errors as one big string. Doesn't help anyone who wants to do things programatticaly though

__Use case:__
Primarily to make it easy for users to consume the influxdb platform APIs and create simple interfaces on top of it.

Contributor guide

Open the contributing guide

Research direction

Start by tracing validation for POST /api/v2/buckets and how its current response returns only the first failure. Compare the proposed structured response with the example failures for name and retentionRules; done means the API reports multiple validation errors in a programmatically consumable format.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.