Commit c017efe
Fix: Restore EntityName after processing nested filter for CosmosDB (#3072)
## Why make this change?
- Closes #3070
- When filtering on multiple different nested objects in CosmosDB (e.g.,
`toOwnership` and `fromOwnership`), the query fails with
`AuthorizationCheckFailed` error even though the user has proper
permissions.
## What is this change?
When processing non-list nested object filters for CosmosDB in
`GQLFilterParser.Parse()`, the `EntityName` property of
`cosmosQueryStructure` is mutated to the nested type name but **not
restored** after the recursive parsing completes.
This causes subsequent nested filters to use the wrong entity name for
authorization checks:
1. First nested filter (e.g., `toOwnership`) → `EntityName` set to
"ToOwnership"
2. `DatabaseObject.Name` and `SourceAlias` are restored ✓
3. `EntityName` is **NOT** restored ✗ (still "ToOwnership")
4. Second nested filter (e.g., `fromOwnership`) → authorization check
uses wrong entity → **fails**
The fix adds a single line to restore `EntityName` alongside the
existing restoration of `DatabaseObject.Name` and `SourceAlias`.
## How was this tested?
- [x] Manual testing against real CosmosDB with nested filter queries
- [x] Integration Tests
- [ ] Unit Tests
### Before fix:
```json
{"errors":[{"message":"Access forbidden to a field referenced in the filter.","extensions":{"code":"AuthorizationCheckFailed"}}],"data":null}
```
### After fix:
```json
{"data":{"transactions":{"items":[{"id":"31654581"},{"id":"28285539"}]}}}
```
## Sample Request(s)
```graphql
# This query failed before the fix
{
transactions(filter: {
toOwnership: { toOwnerType: { eq: "Privat" } },
fromOwnership: { fromOwnerType: { eq: "Privat" } }
}, first: 2) {
items { id }
}
}
```
---------
Co-authored-by: Aniruddh Munde <[email protected]>1 parent b0ecbf6 commit c017efe
2 files changed
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
899 | 899 | | |
900 | 900 | | |
901 | 901 | | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
902 | 927 | | |
903 | 928 | | |
904 | 929 | | |
| |||
0 commit comments