-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: update necessary if shadow cleared #196
Conversation
Test? |
67ad0c3
to
64ee734
Compare
64ee734
to
f21c308
Compare
@@ -242,9 +242,7 @@ public UpdateThingShadowHandlerResponse handleRequest(UpdateThingShadowRequest r | |||
.withVersion(updatedDocument.getVersion()) | |||
.withClientToken(clientToken) | |||
.withTimestamp(Instant.now()) | |||
// explicitly convert to shadow document to return valid state. | |||
// this is to prevent edge cases like returning null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to think that returning null is bad... so do we think this is a problem for our customers? Does the cloud shadow service ever return null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my initial understanding was wrong, cloud shadow service does return null for update accepted topic. verified using the IoT mqtt test client and a real shadow
*/ | ||
@Setter | ||
@JsonIgnore | ||
private boolean clear; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? We cannot handle nulls without this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can, although we use shadowDocument.state a bunch of places in the code. thinking was that this would be better than adding null checks everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what it would look like of course, but I think that marking state as @Nullable
and then handling the null case would make more sense.
@@ -28,6 +29,7 @@ | |||
* Class for managing operations on the Shadow Document. | |||
*/ | |||
@Getter | |||
@JsonDeserialize(using = ShadowDocumentDeserializer.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using a custom deserializer and new clear
field seemed less invasive than allowing ShadowDocument#state to be null, since we'd have to add null checks everywhere ShadowDocument is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The document isn't null though right, just state
inside the document is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah just the state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did a code search and it's less cases of this than what i thought, will refactor
src/main/java/com/aws/greengrass/shadowmanager/model/ShadowDocument.java
Show resolved
Hide resolved
Unit Tests Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against fc7890b |
Integration Tests Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against fc7890b |
Check on the UAT failure as well. https://github.com/aws-greengrass/aws-greengrass-shadow-manager/actions/runs/6475607422/job/17582906225?pr=196 |
yep, still digging in |
Looks unrelated to this PR
|
aws-greengrass/aws-greengrass-testing#226 |
May be related to aws-greengrass/aws-greengrass-testing#226, UAT runs after this have been failing |
Issue #, if available:
Description of changes:
Ensure the cloud update document
{"state": null}
isn't ignored.Currently, if a null cloud shadow update accepted document is received,
{"state": null}
, shadow manager will discard the update, because it thinks no change was made to the cloud state after merging the existing cloud document with{"state": null}
:To disambiguate between null and empty, we can explicitly check the update request,
{"state": null}
, withinisUpdateNecessary
.In order to enable this comparison, we need to allow
ShadowDocument#state
to benull
, which required some refactoring to support.Why is this change necessary:
To allow null cloud shadow updates
{"state": null}
to be accepted by shadow manager, which will subsequently clear the local shadow.How was this change tested:
A new integration test has been added, and we have UAT coverage as well, which is how the issue was initially discovered.
Any additional information or context required to review the change:
Checklist:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.