Skip to content

fix(spec): METHOD_BINDING_MISMATCH never fires for validation-carrying handlers #368

Description

@yeongseon

Context

PR #366 (#362) added WarningCode.METHOD_BINDING_MISMATCH to flag an explicit @openapi(method=...) that the HTTP binding does not serve. However, the _binding_methods stamp that spec._collect_binding_mismatch_warnings() reads is only written at bridge.py:157, inside _reconcile_openapi_binding().

_reconcile_openapi_binding() is reached only for plain @openapi handlers (no endpoint/validation metadata) via the early-continue at bridge.py:558. Handlers that carry validation/endpoint metadata and an explicit @openapi(method=X) proceed into the metadata-merge path below, which never stamps _binding_methods. As a result, METHOD_BINDING_MISMATCH never surfaces for those handlers — the most common real-world case.

Surfaced by the Copilot review on PR #366 (comment on spec.py:856).

Acceptance Checklist

  • Stamp _binding_methods on the merged entry in the metadata-carrying scan path when the entry's method came from an explicit @openapi(method=...).
  • METHOD_BINDING_MISMATCH fires for a validation-carrying handler whose explicit method is absent from the binding's served verbs.
  • No false positives for unspecified-method bindings or subset/inferred methods.
  • Regression tests cover the validation-carrying positive and negative cases.
  • make check-all passes with coverage >= 95%.

Out of scope

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:p2Normal / later

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions