Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum value not parsed for in query operator #3120

Open
XVincentX opened this issue Nov 13, 2024 · 5 comments
Open

Enum value not parsed for in query operator #3120

XVincentX opened this issue Nov 13, 2024 · 5 comments

Comments

@XVincentX
Copy link

Request URL Forwarded URL
/identityProtection/RiskyUsers?$filter=riskLevel eq 'low' identityProtection/riskyUsers?$filter=riskLevel+eq+Microsoft.IdentityProtectionServices.riskLevel'low'
/identityProtection/RiskyUsers?$filter=riskLevel in ('low') /identityProtection/riskyUsers?$filter=riskLevel+in+('low')

ODL doesn't parse the value as Enum for the in case.

@xuzhg
Copy link
Member

xuzhg commented Nov 14, 2024

@XVincentX

Filter using binary operator

http://~?$filter=Shape eq 'Rectangle'

BinaryOperatorNode
  |-- SingleValuePropertyAccessNode: Shape
  |-- ConstNode: Fully.Qualified.Namespace.NonFlagShape , Literal: 'Rectangle'

Filter using in operator

http://~?$filter=Shape in ('Rectangle', 'Triangle')

InNode
  |-- SingleValuePropertyAccessNode: Shape
  |-- CollectionConstantNode:
    |-- ConstNode: Fully.Qualified.Namespace.NonFlagShape , Literal: Rectangle
    |-- ConstNode: Fully.Qualified.Namespace.NonFlagShape , Literal: Triangle

So, It seems OData can successfully parse the enum value in the 'in' operator. Of course, same as the binary operator, it outputs the 'ConstantNode' for the potential enum literal. Good news is that the ConstNode type gives the correct type information.

So, I don't know where you get the 'Forwarded URL'. What doesn't it mean and where do you get this URL?

@XVincentX
Copy link
Author

I don't know where you get the 'Forwarded URL'. What doesn't it mean and where do you get this URL?

@xuzhg That is basically the URL that gets forwarded to the workload from the Aggregator Service

@xuzhg
Copy link
Member

xuzhg commented Nov 14, 2024

I don't know where you get the 'Forwarded URL'. What doesn't it mean and where do you get this URL?

@xuzhg That is basically the URL that gets forwarded to the workload from the Aggregator Service

Then, I think it's a gap within AGS.

@syprieur
Copy link
Contributor

@xuzhg: concern is observed inconsistent behavior between 'eq' and 'in' (processing of single-item vs collection).
It may or may not be due to specific URI resolvers (e.g. StringAsEnum).

Could you please try this repro?

  1. http://~?$filter=Shape eq 'EnumValueWhichDoesNotExist'
  2. http://~?$filter=Shape in ('EnumValueWhichDoesNotExist')

With AGS Uri resolver, we get:

  1. Microsoft.OData.ODataException: 'The string 'EnumValueWhichDoesNotExist' is not a valid enumeration type constant.'
  2. InNode
    |-- SingleValuePropertyAccessNode: Shape
    |-- CollectionConstantNode:
    |-- ConstNode: Fully.Qualified.Namespace.NonFlagShape , Literal: EnumValueWhichDoesNotExist

@syprieur
Copy link
Contributor

syprieur commented Nov 15, 2024

In the first case, exception is thrown by the StringAsEnumResolver, in method:
PromoteBinaryOperandTypes(BinaryOperatorKind binaryOperatorKind, ref SingleValueNode leftNode, ref SingleValueNode rightNode, out IEdmTypeReference typeReference)

Note that ODataUriResolver doesn't seem to have an overload for CollectionNode instead of SingleValueNode as rhs. That may be why the collection case doesn't throw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants