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

req.json_body result is an empty object for specific types #165

Closed
malud opened this issue Mar 29, 2021 · 1 comment · Fixed by #177
Closed

req.json_body result is an empty object for specific types #165

malud opened this issue Mar 29, 2021 · 1 comment · Fixed by #177
Assignees
Labels
bug Something isn't working
Milestone

Comments

@malud
Copy link
Collaborator

malud commented Mar 29, 2021

Describe the bug
The variable req.json_body does not return the expected outcome.

To Reproduce
Steps to reproduce the behavior:

  1. Which Couper version? Run couper version or docker run --entrypoint=/couper avenga/couper version
    master 2021-03-29 acfce46
  2. Provide your configuration file *.hcl. Remove sensitive data.
server "api" {
  api {
    base_path = "/api"

    endpoint "/req" {
      response {
#        body = json_encode(req.json_body)
        body = json_encode([1,2,3])
      }
    }
  }
}
  1. Provide a curl call for reproduction
    curl -s -H "Content-Type: application/json" -d "[1,2,3]" localhost:8080/api/req|jq

Expected behavior

  • json_encode([1,2,3]): got expected
 [
  1,
  2,
  3
]
  • json_encode(req.json_body) got empty object, expected array with 1, 2, 3
 {}

Additional context
This happens with boolean, number, string or array values.

@malud malud added the bug Something isn't working label Mar 29, 2021
@malud malud added this to the 1.0 milestone Mar 29, 2021
@malud
Copy link
Collaborator Author

malud commented Apr 1, 2021

At the moment we assume an object instead of an array as root which is the cause for the empty result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant