Skip to content

Fix contained navigation paths when keys are missing - #3589

Merged
xuzhg merged 3 commits into
mainfrom
issue3150759
Aug 24, 2026
Merged

xuzhg merged 3 commits into
mainfrom
issue3150759

Conversation

@xuzhg

@xuzhg xuzhg commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Recover contained writer scope paths from explicit resource IDs when key properties are unavailable. Add scenario coverage for relative, absolute, nested collection, and invalid IDs.

Issues

This pull request fixes ADO issue: #3150759.

Description

Briefly describe the changes of this pull request.

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.

Repository notes

Team members can start a CI build by adding a comment with the text /AzurePipelines run to a PR. A bot may respond indicating that there is no pipeline associated with the pull request. This can be ignored if the build is triggered.

Team members should not trigger a build this way for pull requests coming from forked repositories. They should instead trigger the build manually by setting the "branch" to refs/pull/{prId}/merge where {prId} is the ID of the PR.

@xuzhg

xuzhg commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

/AzurePipelines run

@xuzhg

xuzhg commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

/AzurePipelines run

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Improve contained-navigation path handling in ODataWriterCore by recovering writer-scope paths from explicit @odata.id values when key properties aren’t available, and add scenario coverage to validate relative/absolute IDs, nested collections, and invalid IDs.

Changes:

  • Add TryBuildPathFromResourceId to parse an ODataPath from an explicit resource ID.
  • Update contained-navigation scope path building to fall back to parsing explicit IDs when the existing path/key info is unavailable.
  • Add scenario tests for nested contained resources/collections (relative + absolute IDs) and invalid-ID behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
test/UnitTests/Microsoft.OData.Core.Tests/ScenarioTests/Writer/ContainedNavigationPathReproTests.cs Adds scenario tests validating contained navigation path recovery from explicit IDs (and a negative case).
src/Microsoft.OData.Core/ODataWriterCore.cs Implements path recovery from explicit resource IDs when key/path info is missing while writing contained elements.

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

Comment thread src/Microsoft.OData.Core/ODataWriterCore.cs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/Microsoft.OData.Core/ODataWriterCore.cs Outdated
WanjohiSammy
WanjohiSammy previously approved these changes Aug 21, 2026
xuzhg added 3 commits August 24, 2026 10:12
Recover contained writer scope paths from explicit resource IDs when key properties are unavailable. Add scenario coverage for relative, absolute, nested collection, and invalid IDs.
Treat recovered resource IDs as complete only when they target a single resource. When an ID resolves to an entity set or collection, append available key properties before building the contained navigation path.

Add regression coverage for a recovered collection path with key properties, while preserving the existing no-duplicate-key coverage for complete resource IDs.
@xuzhg

xuzhg commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

/AzurePipelines run

@xuzhg
xuzhg merged commit 05dc532 into main Aug 24, 2026
3 checks passed
xuzhg added a commit that referenced this pull request Aug 25, 2026
* Fix contained navigation paths when keys are missing

Recover contained writer scope paths from explicit resource IDs when key properties are unavailable. Add scenario coverage for relative, absolute, nested collection, and invalid IDs.

* Address contained path review feedback

* Handle collection-only resource IDs

Treat recovered resource IDs as complete only when they target a single resource. When an ID resolves to an entity set or collection, append available key properties before building the contained navigation path.

Add regression coverage for a recovered collection path with key properties, while preserving the existing no-duplicate-key coverage for complete resource IDs.
xuzhg added a commit that referenced this pull request Aug 25, 2026
Recover contained writer scope paths from explicit resource IDs when key properties are unavailable. Cover relative, absolute, nested collection, invalid, and collection-only IDs.

Determine whether a recovered path identifies one resource from the terminal segment's SingleResult and resource target metadata rather than ODataPath.IsCollection, which cannot translate every valid segment kind. This preserves type-cast resource IDs and rejects collection or non-resource paths as complete entity paths.

Parse relative explicit IDs with the relative ODataUriParser overload so path recovery works without a service root. Continue requiring a service root for absolute IDs.

Add regressions for type-cast IDs, relative IDs without a service root, and collection paths that cannot identify the current resource without a key.
xuzhg added a commit that referenced this pull request Aug 25, 2026
Recover contained writer scope paths from explicit resource IDs when key properties are unavailable. Cover relative, absolute, nested collection, invalid, and collection-only IDs.

Determine whether a recovered path identifies one resource from the terminal segment's SingleResult and resource target metadata rather than ODataPath.IsCollection, which cannot translate every valid segment kind. This preserves type-cast resource IDs and rejects collection or non-resource paths as complete entity paths.

Parse relative explicit IDs with the relative ODataUriParser overload so path recovery works without a service root. Continue requiring a service root for absolute IDs.

Add regressions for type-cast IDs, relative IDs without a service root, and collection paths that cannot identify the current resource without a key.
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.

4 participants