shreemaan-abhishek opened a new issue, #14161:
URL: https://github.com/apache/apisix/issues/14161

   ## Current Behavior
   
   `openapi-to-mcp` sends a second literal `?` upstream when a path template 
carries a query
   suffix and the operation also declares query parameters.
   
   `build_path()` returns the template with its substitutions, query suffix 
included, and
   `_M.call()` then appends the serialized query parameters with its own `?`:
   
   ```lua
   local url = base_url .. path
   if query then
       url = url .. "?" .. query
   end
   ```
   
   For a template of `/{Bucket}?acl` with a declared `prefix` query parameter, 
a call with
   `Bucket=b` and `prefix=logs` is sent as:
   
   ```
   /b?acl?prefix=logs
   ```
   
   The upstream parses everything after the first `?` as the query string, so 
it sees one
   parameter spelled `acl?prefix`, and the declared `prefix` parameter never 
arrives under
   its own name. Query-suffixed path templates are used by S3-style documents.
   
   Verified at runtime against the official test harness on `master`; the 
output is identical
   on #14154, so the behavior is pre-existing and that PR neither introduces 
nor changes it.
   It surfaced while reviewing #14154, which added the first test coverage for 
query-suffixed
   templates: https://github.com/apache/apisix/pull/14154#discussion_r4475591464
   
   ## Expected Behavior
   
   The template's query suffix and the serialized query parameters should be 
merged into one
   query string joined by `&`, so the example above is sent as 
`/b?acl&prefix=logs` and every
   declared parameter reaches the upstream under its own name.
   
   ## Steps to Reproduce
   
   1. Serve an OpenAPI document whose path is `/{Bucket}?acl`, with `Bucket` as 
a required
      path parameter and `prefix` as a query parameter.
   2. Configure an `openapi-to-mcp` Route using that document.
   3. Call the generated tool with `Bucket=b` and `prefix=logs`.
   4. Observe the upstream request path `/b?acl?prefix=logs` rather than 
`/b?acl&prefix=logs`.
   
   ## Environment
   
   - APISIX: current `master`, reproduced at `6205e4a56`
   - Component: `apisix/plugins/openapi-to-mcp/tools/handler.lua`, 
`build_path()` and `_M.call()`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to