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

NullPointerException for list request with incorrect attributes or excludedAttributes query param #790

Open
DmitriLo7 opened this issue Jan 13, 2025 · 1 comment

Comments

@DmitriLo7
Copy link

DmitriLo7 commented Jan 13, 2025

Hi,

Noted that attributes or excludedAttributes query params is incorrectly processed if value contains more than 1 dot.

Example calls:
../Users?excludedAttributes=part1.part2.part3
../Users?attributes=part1.part2.part3

Produces 500 error code with response:
{
"detail": "An internal error has occurred.",
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:Error"
],
"status": 500
}

Debug log contains the following message:

Caused by: java.lang.NullPointerException: Cannot invoke "String.replaceFirst(String, String)" because "scimNodeName" is null
at de.captaingoldfish.scim.sdk.common.schemas.Schema.lambda$getSchemaAttribute$4(Schema.java:277)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at de.captaingoldfish.scim.sdk.common.schemas.Schema.getSchemaAttribute(Schema.java:276)
at de.captaingoldfish.scim.sdk.server.utils.RequestUtils.lambda$getSchemaAttribute$3(RequestUtils.java:330)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at de.captaingoldfish.scim.sdk.server.utils.RequestUtils.getSchemaAttribute(RequestUtils.java:332)
at de.captaingoldfish.scim.sdk.server.utils.RequestUtils.getSchemaAttributeByAttributeName(RequestUtils.java:268)
at de.captaingoldfish.scim.sdk.server.utils.RequestUtils.lambda$getAttributes$0(RequestUtils.java:94)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at de.captaingoldfish.scim.sdk.server.utils.RequestUtils.getAttributes(RequestUtils.java:95)
at de.captaingoldfish.scim.sdk.server.endpoints.ResourceEndpointHandler.listResources(ResourceEndpointHandler.java:552)

Expected result: 400 status code is reported with response:
{
"detail": "Attribute 'part1.part2.part3' is unknown to resource type 'User'",
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:Error"
],
"status": 400,
"scimType": "invalidPath"
}

@Captain-P-Goldfish
Copy link
Owner

sorry for the late reply.
I actually do not consider this a bug, but I should add a validation to schema-registration that forbids using .-characters in attribute-names.
.-characters must not be used in attribute-names because the dot is reserved-character that is used to determine attribute-paths.
I leave this ticket open until I added an appropriate validation to schema registration

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

2 participants