Reject RetrieveMultiple queries filtering on non-existent attributes#342
Merged
Conversation
Mirror Dataverse: a filter condition referencing an attribute that does not exist on the targeted entity now faults with an OrganizationServiceFault instead of being silently ignored. Validation runs after alias-filling so link-criteria conditions resolve against the correct entity's metadata, and the attribute lookup is case-sensitive. Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates RetrieveMultiple behavior to better mirror Dataverse by faulting when a filter condition references an attribute that doesn’t exist on the targeted entity (including link-entity criteria), rather than silently ignoring the condition.
Changes:
- Add filter-attribute validation to
RetrieveMultipleRequestHandlerafter alias filling, throwingFaultException<OrganizationServiceFault>on invalid attributes (case-sensitive lookup). - Add unit tests covering invalid/valid attribute filters for
QueryExpression,FetchExpression, andLinkEntitycriteria. - Add required
System.ServiceModelreference for the new fault-based assertions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tests/XrmMockup365Test/TestRetrieveMultiple.cs | Adds tests asserting faults for invalid filter attributes (including case-sensitivity and link criteria). |
| src/XrmMockup365/Requests/RetrieveMultipleRequestHandler.cs | Adds validation that rejects filters referencing non-existent attributes (post-alias fill) to match Dataverse behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot review feedback: FillAliasIfEmpty only assigns an alias when it is null, so a link with an explicit empty-string EntityAlias kept it and its criteria were skipped by the new attribute validation. Fall back to the linked entity's logical name as the scope key so those filters are still validated. Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
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.
Mirror Dataverse: a filter condition referencing an attribute that does not exist on the targeted entity now faults with an OrganizationServiceFault instead of being silently ignored. Validation runs after alias-filling so link-criteria conditions resolve against the correct entity's metadata, and the attribute lookup is case-sensitive.