Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Unable to use the route filter metadata #284

@Brunomachadob

Description

@Brunomachadob

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions