Skip to content

Shadow::HandleGetResponse does not notify about Rejected responses #86

@shekharhimanshu

Description

@shekharhimanshu

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions