Describe the bug
When the local shadow on a Greengrass deployment is updated with a desired state of null for a nested field (the accepted method to remove the field's state from the shadow), Shadow Manager throws a NullPointerException, presumably when it attempts to calculate a delta.
To Reproduce
First, send a payload to Shadow Manager such as:
{"state": {"desired": {"mystate": {"mysub": "123"}}}}
Then send a payload after that:
{"state": {"desired": {"mystate": {"mysub": null}}}}
Expected behavior
The expectation is that the field mysub in my example should be removed from the shadow document without any errors.
Actual behavior
A NullPointerException is thrown and continues to be thrown whenever other subsequent shadow updates are attempted until the null is cleared from the document by another update to the shadow for field mysub with a value other than null.
The NullPointerException is:
[ERROR] (AwsEventLoop 1) com.aws.greengrass.ipc.common.ExceptionUtil: Unhandled exception in IPC. {}
java.lang.NullPointerException
at com.aws.greengrass.shadowmanager.model.ShadowStateMetadata.buildMetadata(ShadowStateMetadata.java:294)
at com.aws.greengrass.shadowmanager.model.ShadowStateMetadata.getDeltaMetadata(ShadowStateMetadata.java:254)
at com.aws.greengrass.shadowmanager.model.ShadowDocument.getDelta(ShadowDocument.java:202)
at com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowRequestHandler.publishDeltaMessage(UpdateThingShadowRequestHandler.java:309)
at com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowRequestHandler.lambda$handleRequest$2(UpdateThingShadowRequestHandler.java:236)
at com.aws.greengrass.ipc.common.ExceptionUtil.translateExceptions(ExceptionUtil.java:33)
at com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowRequestHandler.handleRequest(UpdateThingShadowRequestHandler.java:94)
at com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowIPCHandler.handleRequest(UpdateThingShadowIPCHandler.java:83)
at com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowIPCHandler.handleRequest(UpdateThingShadowIPCHandler.java:29)
at software.amazon.awssdk.eventstreamrpc.OperationContinuationHandler.onContinuationMessage(OperationContinuationHandler.java:324)
at software.amazon.awssdk.crt.eventstream.ServerConnectionContinuationHandler.onContinuationMessageShim(ServerConnectionContinuationHandler.java:53)
Environment
- OS: Raspbian 12 Bookworm
- JDK version: 11.0.28
- Nucleus version: 2.15.0
- Shadow Manager version: 2.3.11
Additional context
In my opinion this bug is quite significant, because when this condition is triggered all shadow management is impacted until the condition is cleared, which might be quite difficult to debug.
Take note that this issue does not occur if the top-level desired state is set to null (mystate in my example above). In that case it works as expected.
Describe the bug
When the local shadow on a Greengrass deployment is updated with a desired state of null for a nested field (the accepted method to remove the field's state from the shadow), Shadow Manager throws a NullPointerException, presumably when it attempts to calculate a delta.
To Reproduce
First, send a payload to Shadow Manager such as:
{"state": {"desired": {"mystate": {"mysub": "123"}}}}Then send a payload after that:
{"state": {"desired": {"mystate": {"mysub": null}}}}Expected behavior
The expectation is that the field
mysubin my example should be removed from the shadow document without any errors.Actual behavior
A NullPointerException is thrown and continues to be thrown whenever other subsequent shadow updates are attempted until the
nullis cleared from the document by another update to the shadow for fieldmysubwith a value other thannull.The NullPointerException is:
Environment
Additional context
In my opinion this bug is quite significant, because when this condition is triggered all shadow management is impacted until the condition is cleared, which might be quite difficult to debug.
Take note that this issue does not occur if the top-level desired state is set to
null(mystatein my example above). In that case it works as expected.