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

[BUG] more informative error messages for double slashes in API call URLs #1499

Closed
pkalliok-aiven opened this issue Nov 3, 2021 · 3 comments
Assignees
Labels
bug Something isn't working distributed framework

Comments

@pkalliok-aiven
Copy link

Describe the bug

If you request (by accident?) a URL with an empty index name, you get a pretty random answer:

$ curl -X PUT -H 'Content-type: application/json' localhost:9200//_cluster/settings?pretty -d '{}'
{
  "error" : {
    "root_cause" : [
      {
        "type" : "string_index_out_of_bounds_exception",
        "reason" : "String index out of range: 0"
      }
    ],
    "type" : "string_index_out_of_bounds_exception",
    "reason" : "String index out of range: 0"
  },
  "status" : 500
}

It would be better to explicitly complain about the double slash or empty index component, I suggest the following error message:

{ "status": 400, "error": { "reason": "empty string is an invalid index name (do you have a double slash in the URL by accident?)" } }

To Reproduce
Steps to reproduce the behavior:

  1. start OpenSearch locally
  2. curl -X PUT -H 'Content-type: application/json' localhost:9200//anything/manything?pretty -d '{}'

Expected behavior
A 400 error with a descriptive error message.

@pkalliok-aiven pkalliok-aiven added bug Something isn't working untriaged labels Nov 3, 2021
@meghasaik
Copy link
Contributor

meghasaik commented Nov 5, 2021

I will look into this.

@meghasaik
Copy link
Contributor

Was able to reproduce the bug by using the steps mentioned by user.

@kartg
Copy link
Member

kartg commented Nov 24, 2021

Looks like all of the related changes are merged. Closing this issue out.

@kartg kartg closed this as completed Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working distributed framework
Projects
None yet
Development

No branches or pull requests

4 participants