Skip to content

fix(openapi): serialize label and matrix path parameter styles - #5857

Closed
BlueX888 wants to merge 2 commits into
PrefectHQ:mainfrom
BlueX888:fix/openapi-path-style-label-matrix
Closed

BlueX888 wants to merge 2 commits into
PrefectHQ:mainfrom
BlueX888:fix/openapi-path-style-label-matrix

Conversation

@BlueX888

Copy link
Copy Markdown
Contributor

Closes #5856

Description

OpenAPI path parameters declared with style: label or style: matrix were substituted as plain path segments (/label/abc, /matrix/abc instead of /label/.abc, /matrix/;id=abc), so endpoints relying on those serialization styles were unusable through the provider. simple (the default) was and remains correct.

What changed

  • RequestDirector.build() now passes the route into _build_url(), which resolves each path parameter's style/explode and delegates to a new _serialize_path_parameter().
  • Implements the OAS style table for label and matrix: scalars, arrays and objects, explode false/true. simple output is byte-for-byte unchanged.
  • Encoding stays per value (quote(..., safe=""), with . kept as %2E where it was before); structural delimiters (., ;, =) are emitted literally. Query, header, and cookie serialization are untouched.

Contribution type

  • Bug fix (simple, well-scoped fix for a clearly broken behavior)
  • Documentation improvement
  • Enhancement

Bug fix verification

Test path: tests/server/providers/openapi/test_path_parameter_styles.py (18 end-to-end tests via OpenAPIProvider + httpx2.MockTransport).

Red at adf90b66 (implementation reverted, final tests applied): 23 failed, 4 passed; the passes are the simple-style controls and traversal pins; all failures are assertion mismatches; no collection errors.

Green at the fix commit: 1730 passed, 1 skipped across tests/server/providers/openapi/ tests/utilities/.

Validation

  • uv run --isolated pytest tests/server/providers/openapi/ tests/utilities/ -q -> 1730 passed, 1 skipped
  • uv run --isolated ruff check and ruff format --check on the changed files -> clean
  • uv run --isolated ty check -> All checks passed

AI assistance

Tool(s) used: Claude Code
How you used it: investigated from a verified reproduction, implemented the style serialization and the regression tests.

Checklist

  • This PR addresses an existing issue (or fixes a self-evident bug)
  • I have read CONTRIBUTING.md
  • I have added tests that cover my changes
  • I have run uv run prek run --all-files and all checks pass (focused checks passed)
  • I have self-reviewed my changes
  • If I used an LLM, it followed the repo's contributing conventions (not generic output)

Path parameters declared with a non-default style were substituted as
plain path segments, so style=label and style=matrix produced `abc`
instead of `.abc` and `;id=abc`.

Serialize label and matrix path parameters per the OpenAPI style table,
including explode variants for arrays and objects, while keeping the
default simple style unchanged. Values are still percent-encoded and the
dot-segment traversal guard is applied per component.
Label-style structural dots can combine with empty components or template
dots to form "." or ".." segments. httpx normalizes those away, so the
request could silently escape the route or the base URL's path. Validate the
fully substituted template after substitution and raise the existing
dot-segment error instead of sending the request.

Also serialize styled (label/matrix) booleans using the OpenAPI true/false
convention, matching query parameter handling; simple style is unchanged.
@github-actions

Copy link
Copy Markdown
Contributor

This pull request is awaiting maintainer assignment. Linked PRs stay open while maintainers triage the issue; this check remains failing until assignment.

Per CONTRIBUTING.md, an external PR must reference an issue that's assigned to its author. To get there:

  1. A maintainer will review the issue and decide whether to assign you. Please don't comment just to request assignment.

Once you're assigned and the link is present, this check is re-run automatically. Previously gate-closed PRs also reopen — no further action needed.

Maintainers: reopen this PR or remove the missing-issue-link label to bypass this check.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T14:43:26.887843Z edfaf67 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@marvin-context-protocol marvin-context-protocol Bot added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. openapi Related to OpenAPI integration, parsing, or code generation features. labels Oct 19, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: edfaf67db6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# each other (or next to template dots) produce "." or "..". httpx
# normalizes those away, silently retargeting the request. Validate the
# fully substituted template to catch such compositions.
if any(part in {".", ".."} for part in url_path.split("/")):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Decode completed paths before the dot-segment check

When an empty label parameter is adjacent to a percent-encoded template dot (for example /api/{id}%2e/admin), substitution produces /api/.%2e/admin, which this raw split("/") comparison accepts. A backend that decodes before normalizing—such as SimpleHTTPRequestHandler, already used in the path-safety tests—interprets that segment as .., so one or more such segments can leave the declared route or base path despite the traversal guard; apply the same decoding/backslash-aware validation used for individual components to the completed path.

AGENTS.md reference: AGENTS.md:L186-L188

Useful? React with 👍 / 👎.

Comment on lines +440 to +444
Path parameters support ``simple`` (the default), ``label`` and
``matrix`` styles. ``simple`` keeps its historical behavior: values are
stringified and encoded as a single segment. ``label`` and ``matrix``
follow the OAS serialization table for scalars, arrays and objects,
including explode variants.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document label and matrix path-array behavior

When specs declare a label or matrix array, this new branch can emit .a.b or ;id=a;id=b, but docs/integrations/openapi.mdx:469 still describes path arrays as comma-separated simple-style values and lines 478-479 call them “always comma-separated.” The newly supported public behavior therefore contradicts the live user contract; revise the Path/Array Parameters documentation to describe the style/explode outputs and the empty-label restrictions.

AGENTS.md reference: AGENTS.md:L166-L166

Useful? React with 👍 / 👎.

@BlueX888

Copy link
Copy Markdown
Contributor Author

Closing this one to reduce review volume, per maintainer feedback. The underlying issue remains open for triage; the branch and tests stay on the fork if it becomes useful later.

@BlueX888 BlueX888 closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. missing-issue-link openapi Related to OpenAPI integration, parsing, or code generation features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] OpenAPI path parameters ignore style: label and style: matrix

1 participant