Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Unable to use the route filter metadata #284

Closed
Brunomachadob opened this issue May 17, 2022 · 6 comments
Closed

Unable to use the route filter metadata #284

Brunomachadob opened this issue May 17, 2022 · 6 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Brunomachadob
Copy link

Brunomachadob commented May 17, 2022

Describe the bug / error

I'm trying to query the route filter metadata, using the GetProperty function, based on the docs: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes

The problem is that I can't get the values I would like from it, using the format I was expecting it to be :{"route_metadata", "envoy.lua", "authorization"} or {"route_metadata", "envoy", "lua", "authorization"}.
Just as a sanity check, {"request", "path"} works as expected.

If I query for the root route_metadata I get an weird string representation.
From the docs, I believe that should be a map or structured values are converted to a sequence of pairs recursively. but apparently it is none of those. I've tried unmarshal the bytes to a map, also without success.

Please check the code and logs bellow.

Would this be a bug or maybe I'm doing something wrong?

What is your Envoy/Istio version?

Tested with Envoy 1.17 and 1.22

What is the SDK version?

v0.18.0

What is your TinyGo version?

tinygo version 0.23.0 darwin/amd64 (using go version go1.17.2 and LLVM version 14.0.0)

URL or snippet of your code including Envoy configuration

routes:
- match:
    prefix: "/"
  route:
    cluster: mockserver
  metadata:
    filter_metadata:
      envoy.lua:
        authorization:
          - TOKEN
func (ctx *httpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) types.Action {
	proxywasm.LogInfo("OnHttpRequestHeaders")

	fieldsToTest := [][]string {
		{"request", "path"},
		{"route_metadata"},
		{"metadata"},
		{"route_metadata", "envoy.lua"},
		{"route_metadata", "envoy.lua", "authorization"},
		{"route_metadata.envoy.lua.authorization"},
	}

	for _, field := range fieldsToTest {
		value, err := proxywasm.GetProperty(field)

		if err != nil {
			proxywasm.LogErrorf("failure: %s", field)
		} else {
			proxywasm.LogInfof("success: %s=%s", field, value)
		}
	}

	return types.ActionContinue
}

Additional context (Optional)

Logs:

proxy_1         | [2022-05-17 18:20:00.633][18][info][wasm] [source/extensions/common/wasm/context.cc:1170] wasm log my_vm: OnHttpRequestHeaders
proxy_1         | [2022-05-17 18:20:00.633][18][info][wasm] [source/extensions/common/wasm/context.cc:1170] wasm log my_vm: success: [request path]=/test
proxy_1         | [2022-05-17 18:20:00.634][18][info][wasm] [source/extensions/common/wasm/context.cc:1170] wasm log my_vm: success: [route_metadata]=
proxy_1         | +
proxy_1         |       envoy.lua
proxy_1         | 
authorization   | 
             2  
proxy_1         | TOKEN
proxy_1         | [2022-05-17 18:20:00.634][18][info][wasm] [source/extensions/common/wasm/context.cc:1170] wasm log my_vm: success: [metadata]=
proxy_1         | [2022-05-17 18:20:00.634][18][error][wasm] [source/extensions/common/wasm/context.cc:1176] wasm log my_vm: failure: [route_metadata envoy.lua]
proxy_1         | [2022-05-17 18:20:00.634][18][error][wasm] [source/extensions/common/wasm/context.cc:1176] wasm log my_vm: failure: [route_metadata envoy.lua authorization]
proxy_1         | [2022-05-17 18:20:00.634][18][error][wasm] [source/extensions/common/wasm/context.cc:1176] wasm log my_vm: failure: [route_metadata.envoy.lua.authorization]

@mathetake mathetake added help wanted Extra attention is needed question Further information is requested labels May 20, 2022
@mathetake
Copy link
Member

maybe you want to take a look at #310

@mathetake
Copy link
Member

as for the list types, I see that Envoy always returns NotFound, which I think is a bug of Envoy.

@Brunomachadob
Copy link
Author

Nice, thanks!
I'll take a look and test this

@mathetake
Copy link
Member

#451

@mathetake
Copy link
Member

#451

@mathetake mathetake reopened this Jul 27, 2024
@mathetake
Copy link
Member

#451

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants