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

backend response status not a number #175

Closed
johakoch opened this issue Mar 31, 2021 · 0 comments · Fixed by #178
Closed

backend response status not a number #175

johakoch opened this issue Mar 31, 2021 · 0 comments · Fixed by #178
Labels
bug Something isn't working
Milestone

Comments

@johakoch
Copy link
Collaborator

Describe the bug
The status from an upstream response cannot be set as status of the client response.

To Reproduce
Steps to reproduce the behavior:

  1. Which Couper version? Run couper version or docker run --entrypoint=/couper avenga/couper version
0 2021-03-31 dev
  1. Provide your configuration file *.hcl. Remove sensitive data.
server "test" {

  api {
    endpoint "/headers" {
      request "second" {
        url = "https://httpbin.org/status/404"
      }
      response {
        status = beresps.second.status
      }
    }
  }
}
  1. Provide a curl call for reproduction
$ curl -i localhost:8080/headers
  1. See an error response or error log.
INFO[0004]                                               backend=default build=dev realtime=660.018 request="map[addr:httpbin.org headers:map[] host:httpbin.org method:GET name:second path: proto:HTTP/1.1 scheme:https]" response="map[headers:map[content-type:text/html; charset=utf-8] proto:HTTP/1.1 tls:true]" status=404 timings="map[connect:112.443 dns:10.312 tls:422.118 ttfb:114.088]" type=couper_backend uid=c1i34j5916bipub2hp1g url="https://httpbin.org:443/status/404" version=0
2021/03/31 10:19:09 http: panic serving 127.0.0.1:65225: not a number
goroutine 34 [running]:
net/http.(*conn).serve.func1(0xc000380000)
        /usr/local/go/src/net/http/server.go:1801 +0x147
panic(0xa4f200, 0xbdfc90)
        /usr/local/go/src/runtime/panic.go:975 +0x47a
github.com/zclconf/go-cty/cty.Value.AsBigFloat(0xbfbbe0, 0xc000026189, 0xa4f200, 0xc000478dd0, 0xc000026101)
        /c/Users/johannes.koch.SEVENVAL/src/couper/vendor/github.com/zclconf/go-cty/cty/value_ops.go:1271 +0x1f0
github.com/avenga/couper/internal/seetie.ValueToInt(0xbfbbe0, 0xc000026189, 0xa4f200, 0xc000478dd0, 0xa4f200)
        /c/Users/johannes.koch.SEVENVAL/src/couper/internal/seetie/convert.go:217 +0x85
github.com/avenga/couper/handler.(*Endpoint).newResponse(0xc000324050, 0xc000396200, 0xc000092230, 0x2, 0xc000092230, 0xc000396200)
        /c/Users/johannes.koch.SEVENVAL/src/couper/handler/endpoint.go:182 +0x771
github.com/avenga/couper/handler.(*Endpoint).ServeHTTP(0xc000324050, 0xbf8c20, 0xc0003a4080, 0xc000396200)
        /c/Users/johannes.koch.SEVENVAL/src/couper/handler/endpoint.go:107 +0x8a6
github.com/avenga/couper/logging.(*AccessLog).ServeHTTP(0xc000323440, 0xbf8c60, 0xc0003a6000, 0xc000396200, 0xbed6c0, 0xc000324050, 0xc01129ff1e0da700, 0xb5898771, 0xf71800)
        /c/Users/johannes.koch.SEVENVAL/src/couper/logging/access_log.go:42 +0x22d
github.com/avenga/couper/server.(*HTTPServer).ServeHTTP(0xc000148980, 0xbf91e0, 0xc0003a0000, 0xc000396000)
        /c/Users/johannes.koch.SEVENVAL/src/couper/server/http.go:210 +0x52a
net/http.serverHandler.ServeHTTP(0xc00012a9a0, 0xbf91e0, 0xc0003a0000, 0xc000396000)
        /usr/local/go/src/net/http/server.go:2843 +0xa3
net/http.(*conn).serve(0xc000380000, 0xbfb420, 0xc00038e000)
        /usr/local/go/src/net/http/server.go:1925 +0x8ad
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2969 +0x36c

Expected behavior
The status from a backend response should be a number, so that it can be used as status for the client response.

@johakoch johakoch added the bug Something isn't working label Mar 31, 2021
@filex filex added this to the 1.0 milestone Mar 31, 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants