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

Empty json array encodes to null. #162

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

Empty json array encodes to null. #162

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

Comments

@malud
Copy link
Collaborator

malud commented Mar 29, 2021

Describe the bug
The array may evaluate to null and therefore encodes respectively to null.

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 "custom-response" {
  endpoint "/**" {
    request {
      url = "https://httpbin.org/anything?a=${req.id}"
      body = json_encode({
        foo = []
        bar = ["bar"]
      })
    }
    response {
      body = json_encode(beresp.json_body.json)
    }
  }
}
  1. Provide a curl call for reproduction

curl -v http://localhost:8080/

Result:

$ http localhost
HTTP/1.1 200 OK
Connection: close
Content-Encoding: gzip
Content-Length: 47
Date: Thu, 18 Mar 2021 18:02:26 GMT
Server: couper.io
Vary: Accept-Encoding
{"bar": ["bar"], "foo": null }

Expected behavior

{"bar": ["bar"], "foo": []}
@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
@filex
Copy link
Contributor

filex commented Mar 30, 2021

Could be related to #165

@malud malud linked a pull request Apr 1, 2021 that will close this issue
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.

2 participants