Skip to content

Cherry-Pick: Fix failure on REST requests with $filter and $orderby parameters#3673

Merged
RubenCerna2079 merged 2 commits into
release/2.0from
dev/rubencerna/cherry-pick-rest
Jun 23, 2026
Merged

Cherry-Pick: Fix failure on REST requests with $filter and $orderby parameters#3673
RubenCerna2079 merged 2 commits into
release/2.0from
dev/rubencerna/cherry-pick-rest

Conversation

@RubenCerna2079

Copy link
Copy Markdown
Contributor

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

)

## 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.ExtractRawQueryParameter to 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/$orderby and %24filter/%24orderby requests.

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.

Comment thread src/Service.Tests/Configuration/ConfigurationTests.cs
Comment thread src/Service.Tests/Configuration/ConfigurationTests.cs
Comment thread src/Core/Parsers/RequestParser.cs
@RubenCerna2079 RubenCerna2079 merged commit 17ae3aa into release/2.0 Jun 23, 2026
12 checks passed
@RubenCerna2079 RubenCerna2079 deleted the dev/rubencerna/cherry-pick-rest branch June 23, 2026 23:34
@github-project-automation github-project-automation Bot moved this from Todo to Done in Data API builder Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Cherry-Pick: Fix failure on REST requests with $filter and $orderby parameters

4 participants