-
Notifications
You must be signed in to change notification settings - Fork 110
Closed
Description
I noticed that Shadow::HandleGetResponse won't call the response handler registered by user when response type is ShadowResponseType::Rejected.
For example, when someone tries to call PerformGetAsync when no shadow exists. (should be fairly easy to reproduce). Shadow::HandleUpdateResponse handles the same case properly.
Something like below should fix the problem:
ResponseCode Shadow::HandleGetResponse(ShadowResponseType response_type, util::JsonDocument &payload) {
if (ShadowResponseType::Delta == response_type) {
AWS_LOG_WARN(SHADOW_LOG_TAG, "Unexpected response type for shadow : %s", thing_name_.c_str());
return ResponseCode::SHADOW_UNEXPECTED_RESPONSE_TYPE;
}
ResponseCode rc = ResponseCode::SHADOW_REQUEST_ACCEPTED;
if (ShadowResponseType::Rejected == response_type) {
AWS_LOG_WARN(SHADOW_LOG_TAG, "Get request rejected for shadow : %s", thing_name_.c_str());
rc = ResponseCode::SHADOW_REQUEST_REJECTED;
else if (!payload.IsObject()
|| !payload.HasMember(SHADOW_DOCUMENT_STATE_KEY)) {
rc = ResponseCode::SHADOW_UNEXPECTED_RESPONSE_PAYLOAD;
} else {
...
}
...
return rc;
}
Metadata
Metadata
Assignees
Labels
No labels