Closed trappa92 closed 5 months ago
Hello @trappa92 ,
Thank you for bringing this issue to our attention. It appears from the stacktrace you provided that a Null Pointer Exception (NPE) occurs when the avars
query parameter is absent. This is certainly something we need to address.
As a temporary workaround, could you please try executing the request with the ?avars={}
parameter, which passes an empty object? This should help us verify if the $ifvar
operator is functioning correctly when avars
is explicitly set to an empty value.
Meanwhile, our team will prioritize fixing the NPE issue that arises when the avars
query parameter is missing.
Additionally, I wanted to note that optional stages in the Change Stream definition, as you mentioned, are indeed available starting from version 7.6.
We appreciate your cooperation as we work to resolve this. Please let us know the outcome of using ?avars={}
in your request.
Hello :)
thanks for your quick answer. I was not very sure for optional stages in the Change Stream definition even there is something saying it in the doc. I confirm, with "?avars={}" it works as expected!
We already implemented the fix, it was super easy. We are going to release 7.7.2 soon
Meanwhile you can test it with the following snapshot build:
$ docker run -p 8080:8080 --rm softinstigate/restheart-snapshot:be7444e
Ps If you find our project useful, we would be delighted if you could give it a star on GitHub. It helps us a lot and motivates our team to continuously improve our work. Thanks
Very helpful and useful! Good work team!
Describe the bug
$ifvar in change streams seems to not working. Is it supposed to work? if i understand, what is possible for aggregations, is possible for change streams. The actual behavior when setting the bellow stage:
if "fruit" is not given, we have this crash: java.lang.NullPointerException: Cannot invoke "org.bson.BsonDocument.containsKey(Object)" because "doc" is null
23:24:25.749 [XNIO-1 task-3] ERROR o.r.m.h.c.GetChangeStreamHandler - Error handling the change stream request java.lang.NullPointerException: Cannot invoke "org.bson.BsonDocument.containsKey(Object)" because "doc" is null at org.restheart.utils.BsonUtils.get(BsonUtils.java:274) at org.restheart.mongodb.utils.StagesInterpolator.stageApplies(StagesInterpolator.java:144) at org.restheart.mongodb.utils.StagesInterpolator._stage(StagesInterpolator.java:160) at org.restheart.mongodb.utils.StagesInterpolator.lambda$interpolate$4(StagesInterpolator.java:71) at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) at java.base/java.util.ArrayList$Itr.forEachRemaining(Unknown Source) at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source) at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source) at org.restheart.mongodb.utils.StagesInterpolator.interpolate(StagesInterpolator.java:73) at org.restheart.mongodb.handlers.changestreams.GetChangeStreamHandler.getResolvedStagesAsList(GetChangeStreamHandler.java:143) at org.restheart.mongodb.handlers.changestreams.GetChangeStreamHandler.startStream(GetChangeStreamHandler.java:151) at org.restheart.mongodb.handlers.changestreams.GetChangeStreamHandler.handleRequest(GetChangeStreamHandler.java:80) at org.restheart.mongodb.handlers.RequestDispatcherHandler.handleRequest(RequestDispatcherHandler.java:132) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.mongodb.handlers.injectors.ETagPolicyInjector.handleRequest(ETagPolicyInjector.java:73) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.mongodb.handlers.injectors.ClientSessionInjector.handleRequest(ClientSessionInjector.java:99) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.mongodb.handlers.OptionsHandler.handleRequest(OptionsHandler.java:83) at org.restheart.mongodb.handlers.ErrorHandler.handleRequest(ErrorHandler.java:75) at org.restheart.handlers.PipelinedWrappingHandler.handleRequest(PipelinedWrappingHandler.java:121) at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:104) at org.restheart.handlers.PipelinedWrappingHandler.handleRequest(PipelinedWrappingHandler.java:121) at org.restheart.mongodb.MongoService.handle(MongoService.java:125) at org.restheart.mongodb.MongoService.handle(MongoService.java:71) at org.restheart.handlers.ServiceWrapper.handleRequest(PipelinedWrappingHandler.java:139) at org.restheart.handlers.PipelinedWrappingHandler.handleRequest(PipelinedWrappingHandler.java:121) at io.undertow.server.handlers.encoding.EncodingHandler.handleRequest(EncodingHandler.java:66) at org.restheart.handlers.ConfigurableEncodingHandler.handleRequest(ConfigurableEncodingHandler.java:81) at org.restheart.handlers.PipelinedWrappingHandler.handleRequest(PipelinedWrappingHandler.java:121) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.QueryStringRebuilder.handleRequest(QueryStringRebuilder.java:92) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.RequestInterceptorsExecutor.handleRequest(RequestInterceptorsExecutor.java:149) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.security.handlers.AuthorizersHandler.handleRequest(AuthorizersHandler.java:65) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.injectors.TokenInjector.handleRequest(TokenInjector.java:62) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:115) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:79) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.security.handlers.AuthenticatorMechanismsHandler.handleRequest(AuthenticatorMechanismsHandler.java:59) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:74) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.security.handlers.SecurityHandler.handleRequest(SecurityHandler.java:58) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.QueryStringRebuilder.handleRequest(QueryStringRebuilder.java:92) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.RequestInterceptorsExecutor.handleRequest(RequestInterceptorsExecutor.java:149) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.injectors.XPoweredByInjector.handleRequest(XPoweredByInjector.java:63) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.CORSHandler.handleRequest(CORSHandler.java:90) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.ServiceExchangeInitializer.handleRequest(ServiceExchangeInitializer.java:106) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.BeforeExchangeInitInterceptorsExecutor.handleRequest(BeforeExchangeInitInterceptorsExecutor.java:85) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.RequestLogger.handleRequest(RequestLogger.java:86) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.TracingInstrumentationHandler.handleRequest(TracingInstrumentationHandler.java:52) at org.restheart.handlers.PipelinedHandler.next(PipelinedHandler.java:80) at org.restheart.handlers.WorkingThreadsPoolDispatcher.handleRequest(WorkingThreadsPoolDispatcher.java:70) at org.restheart.handlers.ErrorHandler.handleRequest(ErrorHandler.java:61) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538) at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282) at java.base/java.lang.Thread.run(Unknown Source)
Can you please help?
Thanks