Background
#13982 fixes query-string loss when apisix.normalize_uri_like_servlet is enabled by appending the current $is_args$args value to $upstream_uri.
Problem
$upstream_uri is materialized before route rewrite and access plugins run. Some plugins modify the live request arguments later. For example, key-auth and jwt-auth remove a query credential through ngx.req.set_uri_args() when hide_credentials is enabled.
Because $upstream_uri already contains a copy of the earlier query string, those later argument changes are not reflected in the URI sent upstream.
Example:
Incoming request: /echo?auth=secret&foo=1
Early upstream_uri: /echo?auth=secret&foo=1
Arguments after key-auth: foo=1
URI sent upstream: /echo?auth=secret&foo=1
Expected upstream URI: /echo?foo=1
The same ordering can affect other plugins that modify request arguments after servlet URI normalization.
Expected behavior
Servlet-style path normalization should preserve the path parameters while the final upstream URI observes query argument changes made by rewrite or access plugins. A plugin that explicitly sets $upstream_uri should continue to take precedence.
Suggested direction
Keep the servlet path separately, then serialize the current $is_args$args value after the relevant plugin phases have completed. Do not overwrite an $upstream_uri explicitly set by a plugin.
Add a regression test covering:
apisix.normalize_uri_like_servlet: true
- query-based
key-auth or jwt-auth
hide_credentials: true
- an unrelated query argument that must still reach the upstream
Related
Background
#13982 fixes query-string loss when
apisix.normalize_uri_like_servletis enabled by appending the current$is_args$argsvalue to$upstream_uri.Problem
$upstream_uriis materialized before route rewrite and access plugins run. Some plugins modify the live request arguments later. For example,key-authandjwt-authremove a query credential throughngx.req.set_uri_args()whenhide_credentialsis enabled.Because
$upstream_urialready contains a copy of the earlier query string, those later argument changes are not reflected in the URI sent upstream.Example:
The same ordering can affect other plugins that modify request arguments after servlet URI normalization.
Expected behavior
Servlet-style path normalization should preserve the path parameters while the final upstream URI observes query argument changes made by rewrite or access plugins. A plugin that explicitly sets
$upstream_urishould continue to take precedence.Suggested direction
Keep the servlet path separately, then serialize the current
$is_args$argsvalue after the relevant plugin phases have completed. Do not overwrite an$upstream_uriexplicitly set by a plugin.Add a regression test covering:
apisix.normalize_uri_like_servlet: truekey-authorjwt-authhide_credentials: trueRelated