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

panic for unsupported IndexExpr #374

Closed
johakoch opened this issue Nov 10, 2021 · 0 comments · Fixed by #389
Closed

panic for unsupported IndexExpr #374

johakoch opened this issue Nov 10, 2021 · 0 comments · Fixed by #389
Labels
bug Something isn't working

Comments

@johakoch
Copy link
Collaborator

Describe the bug
I want to use an environment variable to configure the name of the verifier cookie:

beta_oidc "oidc" {
  ...
  verifier_value = request.cookies[env.VERIFIER_COOKIE_NAME]
}

However, this results in a panic in eval.value.go (clone()) line 241:

	default:
		panic("eval: unsupported expression: " + reflect.TypeOf(exp).String())

The unsupported expression is of type *hclsyntax.IndexExpr.

BTW,

beta_oidc "oidc" {
  ...
  verifier_value = request.cookies["foo"]
}

works.

To Reproduce
Steps to reproduce the behavior:

  1. Which Couper version? 1.5

  2. Provide your configuration file *.hcl. Remove sensitive data.

see above

  1. Provide a curl call for reproduction
    3.1 You may use your browsers developer console and hit copy as curl.

  2. See an error response or error log.

2021/11/10 13:23:05 http: panic serving 127.0.0.1:54298: invalid WriteHeader code 0
goroutine 36 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go/src/net/http/server.go:1801 +0xb9
panic({0xbd1d80, 0xc000646460})
        /usr/local/go/src/runtime/panic.go:1047 +0x266
net/http.checkWriteHeaderCode(...)
        /usr/local/go/src/net/http/server.go:1089
net/http.(*response).WriteHeader(0xc0003c40e0, 0x0)
        /usr/local/go/src/net/http/server.go:1123 +0x5c8
github.com/avenga/couper/server/writer.(*Gzip).writeHeader(0xc0002de800)
        /c/Users/johannes.koch.SEVENVAL/src/couper/server/writer/gzip.go:138 +0x22d
github.com/avenga/couper/server/writer.(*Gzip).Close(0xc0002de800)
        /c/Users/johannes.koch.SEVENVAL/src/couper/server/writer/gzip.go:96 +0x4e
github.com/avenga/couper/handler/middleware.NewRecordHandler.func1.1.1()
        /c/Users/johannes.koch.SEVENVAL/src/couper/handler/middleware/status.go:24 +0x6e
panic({0xbd1d80, 0xc000646450})
        /usr/local/go/src/runtime/panic.go:1038 +0x215
github.com/avenga/couper/eval.clone({0xe3ce90, 0xc0000c6c40})
        /c/Users/johannes.koch.SEVENVAL/src/couper/eval/value.go:241 +0xdb9
github.com/avenga/couper/eval.Value(0xc247e0, {0xe3ce90, 0xc0000c6c40})
        /c/Users/johannes.koch.SEVENVAL/src/couper/eval/value.go:51 +0x77
github.com/avenga/couper/eval.ValueFromAttribute(0xc0002793f0, 0xc00063c840, {0xd0e559, 0xe3ccd0})
        /c/Users/johannes.koch.SEVENVAL/src/couper/eval/value.go:38 +0x46
github.com/avenga/couper/eval.ValueFromBodyAttribute(0xc000223310, {0xe3cdb0, 0xc0002793f0}, {0xd0e559, 0xe})
        /c/Users/johannes.koch.SEVENVAL/src/couper/eval/value.go:29 +0xe8
github.com/avenga/couper/oauth2.AbstractAcClient.GetTokenResponse({{0xe36be8, 0xc0002864c0}, {{0xe25960, 0xc0000468e0}, {0xe34688, 0xc000223310}, {0x7f81b4aeaf58, 0xc000223310}}, {0xc000043d98, 0x4}}, ...)
        /c/Users/johannes.koch.SEVENVAL/src/couper/oauth2/ac.go:67 +0x507
github.com/avenga/couper/accesscontrol.(*OAuth2Callback).Validate(0xc00050bcd0, 0xc00021c700)
        /c/Users/johannes.koch.SEVENVAL/src/couper/accesscontrol/oauth2.go:32 +0xc8
github.com/avenga/couper/accesscontrol.ListItem.Validate({{0xe25680, 0xc00050bcd0}, {0xe257e0, 0xc00050beb0}, {0xc0002326c0, 0xe}, {0xc000127598, 0x4}}, 0xc00021c700)
        /c/Users/johannes.koch.SEVENVAL/src/couper/accesscontrol/ac.go:43 +0x8a
github.com/avenga/couper/handler.(*AccessControl).ServeHTTP(0xc000132270, {0xe36c48, 0xc0004a4120}, 0xc00021c700)
        /c/Users/johannes.koch.SEVENVAL/src/couper/handler/access_control.go:30 +0x131
github.com/avenga/couper/server.(*HTTPServer).ServeHTTP(0xc000218780, {0xe36c48, 0xc0004a4120}, 0xc00021c700)
        /c/Users/johannes.koch.SEVENVAL/src/couper/server/http.go:242 +0x9fb
github.com/avenga/couper/handler/middleware.(*TraceHandler).ServeHTTP(0xc00050bf80, {0xe36c48, 0xc0004a4120}, 0xc00021c700)
        /c/Users/johannes.koch.SEVENVAL/src/couper/handler/middleware/trace.go:48 +0x7c2
github.com/avenga/couper/handler/middleware.(*UID).ServeHTTP(0xc000133080, {0xe36c48, 0xc0004a4120}, 0xc00021c700)
        /c/Users/johannes.koch.SEVENVAL/src/couper/handler/middleware/uid.go:56 +0x4cc
github.com/avenga/couper/logging.(*AccessLog).ServeHTTP(0xc000235b00, {0xe36c48, 0xc0004a4120}, 0xc00021c700, {0xe258e0, 0xc000133080})
        /c/Users/johannes.koch.SEVENVAL/src/couper/logging/access_log.go:42 +0x62
github.com/avenga/couper/server.New.func1({0xe36c48, 0xc0004a4120}, 0x1372201)
        /c/Users/johannes.koch.SEVENVAL/src/couper/server/http.go:100 +0x3b
net/http.HandlerFunc.ServeHTTP(0xe3cbb8, {0xe36c48, 0xc0004a4120}, 0x1372240)
        /usr/local/go/src/net/http/server.go:2046 +0x2f
github.com/avenga/couper/handler/middleware.NewRecordHandler.func1.1({0xe37728, 0xc0003c40e0}, 0xc00021c700)
        /c/Users/johannes.koch.SEVENVAL/src/couper/handler/middleware/status.go:30 +0x373
net/http.HandlerFunc.ServeHTTP(0xe3cb10, {0xe37728, 0xc0003c40e0}, 0x1372268)
        /usr/local/go/src/net/http/server.go:2046 +0x2f
github.com/avenga/couper/server.New.func2({0xe37728, 0xc0003c40e0}, 0xc00021c600)
        /c/Users/johannes.koch.SEVENVAL/src/couper/server/http.go:104 +0x2b6
net/http.HandlerFunc.ServeHTTP(0xc0000e40fb, {0xe37728, 0xc0003c40e0}, 0x4642ee)
        /usr/local/go/src/net/http/server.go:2046 +0x2f
net/http.serverHandler.ServeHTTP({0xc000554180}, {0xe37728, 0xc0003c40e0}, 0xc00021c600)
        /usr/local/go/src/net/http/server.go:2878 +0x43b
net/http.(*conn).serve(0xc000522140, {0xe3cbb8, 0xc0001680c0})
        /usr/local/go/src/net/http/server.go:1929 +0xb08
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:3033 +0x4e8
...

Expected behavior
I expect the index with an env variable expression to work.

@johakoch johakoch added the bug Something isn't working label Nov 10, 2021
@johakoch johakoch linked a pull request Nov 23, 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.

1 participant