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

Xpack roles:elastic: Error 400 (Bad Request): request body is required [type=parse_exception] #49

Closed
andrescolodrero opened this issue Dec 18, 2019 · 9 comments
Labels

Comments

@andrescolodrero
Copy link

andrescolodrero commented Dec 18, 2019

Im having this error:
Error 400 (Bad Request): request body is required [type=parse_exception]

On a 7.5.0 Cluster,
with this configuration:

resource "elasticsearch_xpack_role" "kibana-admin" {
  role_name = "kibana-admin"
  indices {
    privileges = ["all"]
    field_security  = "*"
    names = ["*"]
  }

  applications {
      application = "kibana-.kibana"
      privileges = ["all"]
      resources = ["*"]

  }
  cluster = ["all"]
}
@phillbaker
Copy link
Owner

@andrescolodrero what version of the provider are you using?

@andrescolodrero
Copy link
Author

@phillbaker sorry, i forget that detail.
im using latest, v0.10.0.

maybe the client for v7 will need an update?

@phillbaker
Copy link
Owner

It looks like there is an issue on 7.5: https://travis-ci.org/phillbaker/terraform-provider-elasticsearch/jobs/626767093#L1400. ESv7.4 and lower don't have issues.

Two potential PRs stand out from the release notes

@phillbaker phillbaker added bug dependency Compatibility issue with upstream or downstream dependency and removed bug labels Jan 2, 2020
@phillbaker
Copy link
Owner

Looks like the tests pass on v7.5 after fixing some permissions that didn't exist, here's the commit: 5387064.

Is it possible that the values you used ended up creating invalid JSON when serialized? Did you get this error on a plan or apply? Can you try running the command again with TF_LOG=INFO and share the (redacted) output?

@andrescolodrero
Copy link
Author

andrescolodrero commented Jan 7, 2020

With same code as before, im getting a new type of error:

Error: Body Error :

on roles.tf line 48, in resource "elasticsearch_xpack_role" "arion-kibana-editor":
48: resource "elasticsearch_xpack_role" "arion-kibana-editor" {

i removed the line:
field_security = "*"

in code is "schema.TypeString",
but on my JSON test is:

        "field_security": {
          "except": [],
          "grant": [
            "*"
          ]   

@phillbaker phillbaker added bug and removed dependency Compatibility issue with upstream or downstream dependency labels Jan 8, 2020
@phillbaker
Copy link
Owner

Hm, I've been able to reproduce that: https://travis-ci.org/phillbaker/terraform-provider-elasticsearch/jobs/634034936#L1231. It comes from:

body, err := json.Marshal(role)
if err != nil {
fmt.Printf("Body : %s", body)
err = fmt.Errorf("Body Error : %s", body)
}

So, the request isn't even being sent, seems like a bug in this provider. Thanks for the additional details.

@phillbaker
Copy link
Owner

@andrescolodrero an update on my side: fixing this will likely require changing the type of the field_security attribute. However, I did want to point out, that from the ES docs:

The absence of field_security in a role is equivalent to * access.

So there's no need to specify field_security": {"except": [],"grant": ["*"], that's the default.

@phillbaker
Copy link
Owner

I believe this was fixed as an outcome of #59. @andrescolodrero can you try v1.0.0 to see if that fixes the issue?

@phillbaker
Copy link
Owner

Going to close this for now, please re-open if this continues to be an issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants