bug: openapi-to-mcp appends a second ? to a query-suffixed path template

Aperta Adatta ai principianti
#14,161 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
83/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
lua, openapi

Direzione di ricerca

Read apisix/plugins/openapi-to-mcp/tools/handler.lua, focusing on build_path() and _M.call(), where the issue identifies the query suffix and serialized parameters being joined. Check the existing tests added in PR #14154 for query-suffixed templates. Done means the example request uses /b?acl&prefix=logs and the declared parameter reaches the upstream under its own name.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 ?:

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()
Lingua principale
Lua
Stelle
17.3k
Fork
3k
Merge medio
3g 12h
PR unite (30g)
58

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/apisix

Tutte le issue di apache/apisix

Issue simili

Altre issue su Lua

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.