Skip to content

fix: TryAddPath exact-match check for duplicate bound operation paths#809

Merged
gavinbarron merged 3 commits intosupport/v1from
fix/tryaddpath-delta-resolution
Apr 14, 2026
Merged

fix: TryAddPath exact-match check for duplicate bound operation paths#809
gavinbarron merged 3 commits intosupport/v1from
fix/tryaddpath-delta-resolution

Conversation

@gavinbarron
Copy link
Copy Markdown
Contributor

Summary

Fixes #808 (OpenAPI 3.0 track of #805)

When processing bound operations, TryAddPath can produce incorrect return types in the generated OpenAPI specification. This happens when a base-type-bound operation (e.g., directoryObject.delta()) is processed before a derived-type-bound operation (e.g., servicePrincipal.delta()), and the duplicate path resolution heuristic incorrectly keeps the base type''s operation.

Problem

In the Microsoft Graph v1.0 CSDL, /servicePrincipals/delta() incorrectly returns Collection(graph.directoryObject) instead of the correct Collection(graph.servicePrincipal).

Root cause: In TryAddPath, when a duplicate path is detected, the method checks if the new operation''s binding type has derived types. If yes, it keeps the first entry assuming it was more specific. This is wrong when the first entry came from a base type and the new entry is the exact match for the entity set.

Fix

Added an exact-match check in TryAddPath (Utils.cs): if the operation''s binding type exactly matches the entity set type (boundEntityType == operationEntityType), always replace the existing entry regardless of derived types.

Changes

  • Utils.cs: Added exact-match guard before the existing derived-types heuristic
  • ODataPathProviderTests.cs: Added regression test that reproduces the scenario with a minimal CSDL model

Testing

All 1224 tests pass (1223 existing + 1 new regression test).

When a duplicate path is detected in TryAddPath, the existing heuristic
checks if the new operation's binding type has derived types and, if so,
keeps the first entry assuming it was more specific. This is incorrect
when the first entry came from a base type (e.g., directoryObject) and
the new entry is the exact match for the entity set (e.g., servicePrincipal).

Add an exact-match check: if the operation's binding type matches the
entity set type, always replace the existing entry regardless of derived
types. This ensures paths like /servicePrincipals/delta() return the
correct type (servicePrincipal) instead of the base type (directoryObject).

Fixes #808

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gavinbarron gavinbarron requested a review from a team as a code owner April 13, 2026 21:04
Reflection of #766 - removes obsolete tool/ build files and UpdateDocs project
references that were causing build failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MIchaelMainer
MIchaelMainer previously approved these changes Apr 13, 2026
…rTests.cs

Co-authored-by: Michael Mainer <8527305+MIchaelMainer@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
75.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@gavinbarron gavinbarron disabled auto-merge April 14, 2026 00:27
@gavinbarron gavinbarron merged commit 115e8f6 into support/v1 Apr 14, 2026
14 of 15 checks passed
@gavinbarron gavinbarron deleted the fix/tryaddpath-delta-resolution branch April 14, 2026 00:36
@gavinbarron gavinbarron linked an issue Apr 14, 2026 that may be closed by this pull request
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.

Fix TryAddPath duplicate bound operation resolution - OpenAPI 3.0

2 participants