Description
The dynamic-endpoint policy routes a request to a named upstreamDefinitions entry via the SDK UpstreamName field. When the targeted upstream definition has a base path (e.g. http://backend:9080/foo), the gateway switches to the correct upstream cluster but does not apply the upstream's base path correctly — the request reaches the backend at the wrong path.
Two root causes in gateway/gateway-runtime/policy-engine/internal/kernel/translator.go:
upstreamDefinitionPaths is looked up by the raw upstream-definition name, but the controller keys that map by the full cluster key (upstream_<Kind>_<UUID>_<name>). The lookup always misses, so the base path is never resolved and defaults to /.
- Even when the base path is resolved, the routed path is built by naive string concatenation that does not strip the API context, producing e.g.
/foo/<context>/v1.0/items instead of /foo/items.
A fix is implemented in commit 5653ee6d0 on branch dynamic-ep, along with an integration test (gateway/it/features/dynamic-endpoint.feature).
Steps to reproduce
- Deploy a RestApi with an
upstreamDefinitions entry whose URL has a base path, e.g. http://sample-backend:9080/foo.
- Attach the
dynamic-endpoint policy to an operation with targetUpstream pointing at that definition.
- Invoke the operation through the gateway.
Expected behavior
The request reaches the backend at <upstream-base-path>/<operation-path> — e.g. /foo/items.
Actual behavior
The upstream base path is dropped, and the API context is left in the forwarded path — e.g. /foo/dynamic-endpoint-routes/v1.0/items.
Version
No response
Related Issue
No response
Description
The
dynamic-endpointpolicy routes a request to a namedupstreamDefinitionsentry via the SDKUpstreamNamefield. When the targeted upstream definition has a base path (e.g.http://backend:9080/foo), the gateway switches to the correct upstream cluster but does not apply the upstream's base path correctly — the request reaches the backend at the wrong path.Two root causes in
gateway/gateway-runtime/policy-engine/internal/kernel/translator.go:upstreamDefinitionPathsis looked up by the raw upstream-definition name, but the controller keys that map by the full cluster key (upstream_<Kind>_<UUID>_<name>). The lookup always misses, so the base path is never resolved and defaults to/./foo/<context>/v1.0/itemsinstead of/foo/items.A fix is implemented in commit
5653ee6d0on branchdynamic-ep, along with an integration test (gateway/it/features/dynamic-endpoint.feature).Steps to reproduce
upstreamDefinitionsentry whose URL has a base path, e.g.http://sample-backend:9080/foo.dynamic-endpointpolicy to an operation withtargetUpstreampointing at that definition.Expected behavior
The request reaches the backend at
<upstream-base-path>/<operation-path>— e.g./foo/items.Actual behavior
The upstream base path is dropped, and the API context is left in the forwarded path — e.g.
/foo/dynamic-endpoint-routes/v1.0/items.Version
No response
Related Issue
No response