pingidentity / scim2

The UnboundID SCIM 2.0 SDK for Java
175 stars 72 forks source link

Parser.parseFilter throwing Invalid attribute path at position 0: Unexpected character ':' when using scim filter "tags.abc:xyz eq \"yes\"" #214

Closed sunnyrush closed 3 months ago

sunnyrush commented 7 months ago

When creating a scim filter and parsing it, it fails to validate. Does it mean one cannot use ":" in left hand side. Can one help understand the issue and any pointers to scim filter spec if its not valid.

com.unboundid.scim2.common.utils.Parser.parseFilter("tags.abc:xyz eq \"yes\"")

Method threw 'com.unboundid.scim2.common.exceptions.BadRequestException' exception.
com.unboundid.scim2.common.exceptions.BadRequestException: Invalid attribute path at position 0: Unexpected character ':' at position 8 for token starting at 5 

scimSdk : "com.unboundid.product.scim2:scim2-sdk-common:2.3.6",

kqarryzada commented 7 months ago

Colons are permitted in attribute names only if they refer to a fully-qualified attribute name. For example, urn:ietf:params:scim:schemas:core:2.0:User:userName is the fully-qualified name for the userName attribute. So there must be a valid schema URN as part of the attribute name, which is not the case in your example.

Also, it's worth noting that it's better to use the Filter class to construct filters. This will throw the same error for the tags.abc:xyz attribute, but it is the preferred way. If this is a filter you're constructing on your own, then you can use:

Filter filter = Filter.eq("attributeName", "yes");

Alternatively, if this is a filter you are processing from a client, you can use:

Filter filter = Filter.fromString(filterString);

The 3.0.0 release has more details for constructing filters, but the Javadoc can be viewed here.