Fix ItemWithPath throwing on null/empty/whitespace path instead of generating malformed URLs#3072
Merged
Merged
Conversation
Co-authored-by: lramosvea <77297467+lramosvea@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix SDK URL construction bug with empty filenames
Fix ItemWithPath throwing on null/empty/whitespace path instead of generating malformed URLs
Mar 9, 2026
gavinbarron
previously approved these changes
May 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR makes ItemWithPath fail fast for invalid path inputs to prevent malformed Microsoft Graph URLs when null, empty, or whitespace strings are provided.
Changes:
- Added argument validation to both
ItemWithPathoverloads (RootRequestBuilderandDriveItemItemRequestBuilder). - Added unit tests covering
null, empty, and whitespace path inputs for both overloads.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tests/Microsoft.Graph.DotnetCore.Test/Requests/Extensions/DriveItemRequestBuilderExtensionsTests.cs | Adds test coverage for invalid path inputs on both ItemWithPath overloads. |
| src/Microsoft.Graph/Extensions/DriveItemRequestBuilderExtensions.cs | Adds null + empty/whitespace validation and normalizes missing leading / for path. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…amName in tests Agent-Logs-Url: https://github.com/microsoftgraph/msgraph-sdk-dotnet/sessions/4583cb48-e9bd-44bd-935f-bf05c5334117 Co-authored-by: gavinbarron <7122716+gavinbarron@users.noreply.github.com>
auto-merge was automatically disabled
May 19, 2026 16:56
Head branch was pushed to by a user without write access
gavinbarron
approved these changes
May 19, 2026
adrian05-ms
approved these changes
May 19, 2026
MIchaelMainer
approved these changes
May 19, 2026
This was referenced May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NormalizePathOrThrowprivate helperStringComparison.Ordinalin second overload'sStartsWithParamName == "path"on thrown exceptionsOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Microsoft Reviewers: Open in CodeFlow