Skip to content

fix(router): preserve rewrite-phase query argument changes during servlet URI normalization #13983

Open

Description

@membphis

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

Activity

  1. Ankit-cs commented on Oct 13, 2026

    @Ankit-cs

    Assign this to me

  2. Ankit-cs commented on Oct 15, 2026

    @Ankit-cs

    thanks @Baoyuantop sir

  3. added a commit that references this issue on Oct 16, 2026
    c1fd74f
  4. Ankit-cs commented on Oct 20, 2026

    @Ankit-cs

    Hey @Baoyuantop sir can you look for the above pr

  5. added 2 commits that reference this issue on Oct 21, 2026
    5b8b473
    155d6a0
  6. ruanweihong-aaa commented on Oct 29, 2026

    @ruanweihong-aaa
    Contributor

    I’ll take this forward.

  7. Ankit-cs commented on Oct 29, 2026

    @Ankit-cs

    But @guoqqqi sir I have worked on the above and my pr is approved ?

  8. guoqqqi commented on Oct 29, 2026

    @guoqqqi
    Member

    18. But @guoqqqi sir I have worked on the above and my pr is approved ?

    Hi, @Ankit-cs Sorry for the confusion. I’ll ask @ruanweihong-aaa to help move your PR review forward and assist with anything needed to get it merged, rather than redo your work.

  9. Ankit-cs commented on Oct 29, 2026

    @Ankit-cs

    OK @guoqqqi sir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions