Skip to content

mcpx(openapi): a path-level parameter redeclared at operation level is never deduplicated — required lists it twice (invalid schema), and same-name parameters in two locations are conflated #1669

Closed

Description

@dezren39

Problem

openapi.Build never applies the OpenAPI parameter-identity rule (pkgs/mcpx/internal/openapi/openapi.go, main c04a943, sha256 79b465b9). Per the spec, a parameter is unique by (name, location), and a parameter declared at path-item level can be overridden at operation level — the operation declaration replaces the shared one, it does not add a second parameter. The code concatenates both lists and treats every entry as distinct, with two observable consequences.

Shape A — an overridden required parameter is duplicated in required: the advertised schema is invalid JSON Schema

  • Build (:312): params := append(append([]Parameter{}, item.Parameters...), op.Parameters...) — no (name, in) dedup anywhere.
  • buildSchema keys properties by name only (:491), so the property entry coincidentally ends up the operation's (matching override semantics), but it appends the name to required once per occurrence (:492-494).
  • Example: path item /pets/{id} declares {name: id, in: path, required: true} and the GET operation redeclares it (the standard override, e.g. to refine its description). The generated tool's inputSchema is {"type":"object","properties":{"id":…},"required":["id","id"]}.
  • JSON Schema requires the elements of required to be unique. The schema mcpx advertises for the tool (via mcpx api tools and the MCP server surface, internal/cli/openapi_tools.go) is therefore invalid for any spec using this spec-sanctioned pattern, and strict MCP clients/validators may refuse the tool outright.

Shape B — same name in two locations: two distinct parameters conflated by the name-keyed schema

  • A query parameter key and a header parameter key are distinct parameters per the spec (uniqueness is name+location), and both may legitimately apply to one operation (one at path level, one at operation level, or both at operation level).
  • The flattened schema can only show one of them: properties is keyed by name (:491), so the later entry's type/description/location note silently replaces the earlier one's — one parameter is invisible to the caller.
  • Call (:565-586) nevertheless iterates both entries in Tool.Params and routes each by its own in, sending the single args["key"] value in both locations. The wire behaviour and the advertised schema describe different operations.

Evidence

  1. Line trace on main c04a943 (file sha256 79b465b9636fa1e51025824ff395e27bf28d0849fcb0c4bd7a2490a097b7cde5): concatenation at :312 with no dedup; props[p.Name] = entry :491; required = append(required, p.Name) :492-494 with no uniqueness check; Call routing loop :565-586 (path :572, header :576-577, default→query :585) iterates every entry in spec.Params. openapi_test.go has no path-item-vs-operation parameter case.
  2. Premise exercised this run with a faithful mirror of the three code paths (goal hidden_files/probe-2026-10-28-laneB-openapi-paramoverride/premise.py + premise.log): shape A → required == ["id","id"]; shape B → schema advertises only the header entry while the mirrored Call sends the value in both query and header.

Disclosure: the prepared Go probe (hidden_files/probe-2026-10-28-laneB-openapi-paramoverride/probe_laneb_test.go, package openapi_test; asserts a duplicate-free required for the override spec and pins shape B's schema/wire conflation against an httptest server) was not executed — the laptop was unreachable this run (SSH tunnel closes immediately) and probes are never compiled on the sandbox. Triage should run the probe first and correct this issue if any verdict differs.

Why it matters

Path-level parameters with operation-level overrides are a normal, spec-endorsed way to write OpenAPI documents (shared path/header parameters refined per operation). For those documents mcpx currently publishes an invalid tool schema, and for same-name cross-location parameters it publishes a schema that does not describe what the call actually sends.

Acceptance criteria

  • Triage runs the prepared probe and confirms/corrects both verdicts.
  • Parameter resolution follows the spec: an operation-level parameter with the same (name, in) as a path-level one replaces it exactly once in Tool.Params and in the schema.
  • Generated inputSchema never contains a duplicated required entry, for any spec; a regression test pins the override pattern.
  • Shape B gets a stated ruling (e.g. schema disambiguation, a Build-time error naming the collision, or documented conflation with matching Call behaviour) pinned by a test — the schema and the wire must not silently disagree.
  • Existing internal/openapi tests pass; specs without path-level parameters are unchanged.

Distinct from #1668 (same package, different defect: map-iteration nondeterminism in name disambiguation and the media pick; this issue is deterministic and concerns parameter identity).

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Oct 28, 2026
  2. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (new-issue-creator-code-b)
    • Session / ID: new-issue-creator-code-b run 2026-10-28 07:50 CDT
    • Found via: filed this run
    • Task: Triage the openapi parameter-identity findings (operation-level override of a path-level parameter duplicates it in required, producing an invalid inputSchema; same-name parameters in two locations are conflated by the name-keyed schema while Call sends both); first step is running the prepared Go probe in the real package on the laptop.
    • Expectation: effort/s — done when (name,in) override resolution is applied exactly once, generated schemas never duplicate a required entry, shape B has a stated ruling pinned by a test, and existing openapi tests stay green.
    • Links: queue packet packet-1669.json (repo-health-code-pilot, triage); related mcpx(openapi): Build is nondeterministic — duplicate operationIds swap tool names between runs, and the body schema is whichever JSON media type the map yields first #1668 (same package, different defect)
  3. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    Intake review

    — fleet monitor intake pass, 2026-10-28T13:45Z

  4. added
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    work/assignedQueue worker lifecycle state
    and removed on Oct 28, 2026
  5. 14 remaining items

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    queue/claimedQueue worker lifecycle state
    and removed
    queue/claimedQueue worker lifecycle state
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 31, 2026
  7. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  8. added a commit that references this issue on Oct 31, 2026
  9. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

    • Agent: queue worker (repo-worker-code), lane C
    • Session / ID: queue task 4228
    • Found via: queue claim (resume from park)
    • Task: PR 3053 merged — openapi parameters now resolve by (name, in), operation overrides path level, same-name/different-location is a Build-time error
    • Expectation: done = PR merged (b50c074), CI run 41201814963 success (lint/plugin/stress/docs/time-budget green; basic:test skipped in that run, openapi tests passed on laptop per prior checkpoint incl. 2 new regression tests), Codex clean @23ce57fdf with no findings/threads
    • Links: PR fix(mcpx): openapi parameters resolve by (name, in) — operation overrides path level (#1669) #3053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions