Skip to content

Fix failure on REST requests with $filter and $orderby parameters#3664

Merged
RubenCerna2079 merged 12 commits into
mainfrom
dev/rubencerna/fix-filter-bug
Jun 17, 2026
Merged

Fix failure on REST requests with $filter and $orderby parameters#3664
RubenCerna2079 merged 12 commits into
mainfrom
dev/rubencerna/fix-filter-bug

Conversation

@RubenCerna2079

@RubenCerna2079 RubenCerna2079 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Why make this change?

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

@RubenCerna2079 RubenCerna2079 marked this pull request as ready for review June 12, 2026 18:41
Copilot AI review requested due to automatic review settings June 12, 2026 18:41
@RubenCerna2079 RubenCerna2079 changed the title Fix bug Fix failure on REST requests with $filter and $orderby parameters Jun 12, 2026

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

This pull request addresses a REST regression (issue #3662) where OData system query options like $filter / $orderby could fail to be extracted from the query string, by normalizing URL-encoded $ (%24) before downstream parsing.

Changes:

  • Normalize %24 to $ in the REST request query string prior to parsing.
  • Add an end-to-end REST test to validate requests using $filter and $orderby succeed.

Reviewed changes

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

File Description
src/Core/Services/RestService.cs Normalizes the raw query string so $-prefixed OData query options can be parsed reliably.
src/Service.Tests/Configuration/ConfigurationTests.cs Adds an end-to-end REST test to prevent regressions for $filter / $orderby query options.

Comment thread src/Service.Tests/Configuration/ConfigurationTests.cs Outdated
Comment thread src/Service.Tests/Configuration/ConfigurationTests.cs Outdated
Comment thread src/Core/Services/RestService.cs Outdated

@souvikghosh04 souvikghosh04 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.

needs some changes on parsing logic and additional tests assesrtion

Comment thread src/Service.Tests/Configuration/ConfigurationTests.cs Outdated
Comment thread src/Core/Services/RestService.cs Outdated
Comment thread src/Service.Tests/Configuration/ConfigurationTests.cs

@souvikghosh04 souvikghosh04 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.

LGTM. thanks for addressing the comments.

@RubenCerna2079 RubenCerna2079 enabled auto-merge (squash) June 17, 2026 03:58
@RubenCerna2079 RubenCerna2079 merged commit 1f486a1 into main Jun 17, 2026
12 checks passed
@RubenCerna2079 RubenCerna2079 deleted the dev/rubencerna/fix-filter-bug branch June 17, 2026 04:32
RubenCerna2079 added a commit that referenced this pull request Jun 18, 2026
)

## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Regression Unable to extract $filter parameter from query string.

5 participants