Skip to content

Preserve endpoints with colliding sanitized path names - #8243

Merged
Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
Shubham-Padkonde:fix/sanitized-path-collision
Sep 21, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
Shubham-Padkonde:fix/sanitized-path-collision

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

Fixes #7143.

Static segments such as /v1.1 and /v11 produce the same navigation name and namespace. Their request builders then overwrite one another, leaving one endpoint inaccessible and potentially exposing the wrong response type.

Resolve sibling collisions before creating the code model. Prefer an already valid segment name, allocate an available Escaped suffix for the conflicting segment, and carry a separate code path through its descendants for namespace generation. Original URI paths remain unchanged. Allocation uses a stable order and reserves existing sibling names so a real v11Escaped endpoint is preserved too.

Four regressions cover both source path orders, with and without an existing suffix name. They check separate navigation targets and both original URL templates; the original two cases fail before the change.

Developed with Codex assistance.

Validation:

  • All 377 builder tests and 59 URL-tree extension tests pass.
  • The unmodified issue description produces only one tests request builder before the fix. Afterward, the generated C# client compiles with .NET 10 and Microsoft.Kiota.Bundle 2.1.2.
  • A local HTTP handler verifies that V11.Tests requests /v11/tests and parses a numeric response, while V11Escaped.Tests requests /v1.1/tests and parses a text response. No external HTTP requests were sent.
  • Generator .NET 10 build and scoped C# formatting verification pass. The build emits worktree SourceLink warnings.

This resolves static segment collisions; it does not change the existing merging rules for parameterized paths.

@baywet

Copy link
Copy Markdown
Member

Shubham Padkonde (@Shubham-Padkonde) your behaviour is disruptive, opening about 30 PRs on the repos in a couple of hours time, most likely code that was AI generated and not tested/reviewed, will only clog our review pipeline. Please stop opening additional pull requests and work on the comments added to existing ones. We have turned on pull requests limits on this repository, and will proceed to blocking you at the organization level if additional pull requests are opened on other repositories before the already opened ones are reviewed and closed/or merged.

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The new collision-resolution loop mixes navigation-name strings with namespace-normalized strings, which can still allow namespace collisions in some cases and should be corrected before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR fixes a Kiota generation bug where sibling static path segments that sanitize to the same navigation name/namespace (e.g. /v1.1 and /v11) would overwrite each other’s request builders, making one endpoint inaccessible and potentially binding the wrong response type.

Changes:

  • Introduces a pre-model disambiguation pass over the OpenAPI URL tree to allocate stable *Escaped suffixes for colliding static segments while preserving original URL templates.
  • Threads a separate “code path” (via node AdditionalData) into namespace generation so descendants remain distinct even when their original segments collide after sanitization.
  • Adds regression coverage to ensure both colliding endpoints (and an already-existing Escaped sibling) remain navigable regardless of source path order.
File Description
tests/​Kiota.Builder.Tests/​KiotaBuilderTests.PathCollision.cs Adds regressions validating distinct navigation targets and preserved original URL templates for colliding static segments.
src/​Kiota.Builder/​KiotaBuilder.cs Runs static-segment disambiguation on the URL tree before building the source model.
src/​Kiota.Builder/​Extensions/​OpenApiUrlTreeNodeExtensions.cs Adds DisambiguateStaticSegments and updates namespace derivation to prefer the disambiguated “code path”.
CHANGELOG.md Documents the new behavior for preserving endpoints with colliding sanitized static segments.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 21, 2026 13:27

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The change is narrowly scoped, includes targeted regressions for the reported collision cases (and ordering), and integrates the disambiguation step at the correct point before code model creation.

Review effort: Lite
Findings: None

Resolved since last review (1)

@baywet
Vincent Biret (baywet) added this pull request to the merge queue Sep 21, 2026
Merged via the queue into microsoft:main with commit d85ec91 Sep 21, 2026
313 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paths /v1.1/ and /v11/ collide

3 participants