Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve validation error messages for DBRP API #20134

Closed
Hualin-AUG opened this issue Nov 20, 2020 · 6 comments · Fixed by #20409
Closed

Improve validation error messages for DBRP API #20134

Hualin-AUG opened this issue Nov 20, 2020 · 6 comments · Fixed by #20409
Assignees
Labels
area/2.x OSS 2.0 related issues and PRs

Comments

@Hualin-AUG
Copy link

Steps to reproduce:
List the minimal actions needed to reproduce the behavior.

  1. Having an InfluxDB Cloud account (free tier)
  2. Setup a bucket and write data into it
  3. Try to do DBRP mapping with following command:

curl --request POST 'https://us-west-2-1.aws.cloud2.influxdata.com/api/v2/dbrps'
--header 'Authorization: Token {my token}'
--header 'Content-type: application/json'
--data '{
"bucketID": "{my bucketID}",
"database": "{some database name}",
"default": true,
"orgID": "{my orgID}",
"retention_policy": "30days"
}'
Expected behavior:
A DBRP should be setup for the bucket I give

Actual behavior:
400 Bad request error happens with following message
{
"code": "invalid",
"message": "invalid ID"
}

Environment info:

  • InfluxDB version: InfluxDB Cloud

Config:
Token I use an all permission token

@rbetts
Copy link
Contributor

rbetts commented Nov 23, 2020

Let's also make the "Invalid ID" error messages disambiguate which ID(s) are invalid. (See re-used errors here: https://github.com/influxdata/influxdb/blob/master/dbrp/http_server_dbrp_test.go#L185).

@timhallinflux
Copy link
Contributor

@Hualin-AUG -- you might also consider trying the updated CLI which now has DBRP commands which should make this a bit easier to manage the mappings themselves. https://docs.influxdata.com/influxdb/v2.0/reference/cli/influx/v1/dbrp/

We'll improve the error messages here in parallel.

@danxmoran danxmoran added the area/2.x OSS 2.0 related issues and PRs label Nov 23, 2020
@danxmoran
Copy link
Contributor

+1 to more specific error messages. In that same direction, I suspect the actual error here is/was that the Cloud implementation expectsbucket_id and organization_id instead of the Swagger-specified bucketID and orgID (it's fixed in OSS but I'm not sure if it's gone through to Cloud yet).

I don't think either impl is validating that requests contain all the expected keys. When there's a mismatch, the system ends up with an empty string for one (or both) IDs, and the empty string fails validation. The most specific validation error would be something like Missing required key: "xxx"

@danxmoran
Copy link
Contributor

@Hualin-AUG if the new CLI tools don't work for you, could you also try using bucket_id instead of bucketID and organization_id instead of orgID in your request payload?

@danxmoran danxmoran self-assigned this Nov 23, 2020
@danxmoran danxmoran changed the title DBRP mapping command Fail Improve validation error messages for DBRP API Nov 23, 2020
@Hualin-AUG
Copy link
Author

@Hualin-AUG if the new CLI tools don't work for you, could you also try using bucket_id instead of bucketID and organization_id instead of orgID in your request payload?

That absolutely solves the problem.

@rbetts
Copy link
Contributor

rbetts commented Nov 23, 2020

@Hualin-AUG thanks for the bug-report. Really helpful as we iron out some usability gotchas here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/2.x OSS 2.0 related issues and PRs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants