Cherry-Pick: Fix failure on REST requests with $filter and $orderby parameters#3673
Open
RubenCerna2079 wants to merge 1 commit into
Open
Cherry-Pick: Fix failure on REST requests with $filter and $orderby parameters#3673RubenCerna2079 wants to merge 1 commit into
RubenCerna2079 wants to merge 1 commit into
Conversation
) ## Why make this change? - Fix issue #3662 This issue is caused by a regression in PR #3080 The regression is that we start using the raw encoded URL and we assume that the `$` character is not encoded when using the `ExtractRawQueryParameter` function, this is half true, since depending on where the URL comes from it will encode it or it will treat it as a special character and leave it as it is. This means the function looks for the `$filter` or `$orderby` when the URL has the possibility to change them to `%24filter` or `%24orderby` which causes the failure. ## What is this change? This change fixes a bug that caused using `$filter` or `$orderby` in REST. This is done by encoding the `parameterName` so that it has the same format as the raw URL, it will only change it if it is unable to find the original `$` character in the raw query. ## How was this tested? - [ ] Integration Tests - [x] Unit Tests Added end to end test to ensure that REST requests that use `$filter` and `$orderby` succeed for both cases where a user uses the special character `$` or its URL encoded format `%24`. ## Sample Request(s) http://localhost:5000/api/Book?$orderby=id desc http://localhost:5000/api/Book?$filter=publisher_id 1234
Contributor
There was a problem hiding this comment.
Pull request overview
Cherry-picks a fix to REST OData query parsing so $filter / $orderby work reliably whether the $ is present literally or URL-encoded as %24, and adds an end-to-end regression test to validate both forms.
Changes:
- Update
RequestParser.ExtractRawQueryParameterto fall back to an encoded parameter name when the raw query string doesn’t contain the unencoded key. - Add an MSSQL end-to-end REST test covering both
$filter/$orderbyand%24filter/%24orderbyrequests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Core/Parsers/RequestParser.cs | Adds fallback handling for URL-encoded query parameter names when extracting raw $filter/$orderby values. |
| src/Service.Tests/Configuration/ConfigurationTests.cs | Adds an MSSQL end-to-end regression test for REST requests using $filter and $orderby in both encoded and unencoded forms. |
| /// options $filter and $orderby succeed to ensure no regression can occur. | ||
| /// </summary> | ||
| [DataTestMethod] | ||
| [DataRow("/api/Book?$orderby=id desc&$filter=publisher_id eq 1234", DisplayName = "REST URL without encoded characters")] |
| out RuntimeConfig deserializedConfig, | ||
| replacementSettings: new(), | ||
| connectionString: GetConnectionStringFromEnvironmentConfig(environment: TestCategory.MSSQL))); | ||
| string configFileName = "custom-config.json"; |
Comment on lines
+325
to
+329
| // Encode the parameterName to ensure it matches the encoding in the query string if the $ sign is URL encoded. | ||
| if (!queryString.Contains(parameterName, StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| parameterName = HttpUtility.UrlEncode(parameterName); | ||
| } |
souvikghosh04
approved these changes
Jun 19, 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.
Why make this change?
This change cherry-picks the PR that fixes the $filter and $orderby parameters
What is this change?
Cherry-picked PRs:
How was this tested?
Existing tests in cherry-pick cover new changes.
Sample Request(s)
N/A