diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index 2a561f0fa3038b..9ef1ccd9aabee7 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -116,8 +116,9 @@ CHIP_ERROR CommandHandler::ProcessCommandDataElement(CommandDataElement::Parser // The Path is not present when there is an error to be conveyed back. ResponseCommandElement would only have status code, // set the error with CHIP_NO_ERROR, then continue to process rest of commands - AddStatusCode(&returnStatusParam, GeneralStatusCode::kInvalidArgument, Protocols::SecureChannel::Id, - Protocols::SecureChannel::kProtocolCodeGeneralFailure); + AddStatusCode(&returnStatusParam, + err == CHIP_ERROR_INVALID_PROFILE_ID ? GeneralStatusCode::kNotFound : GeneralStatusCode::kInvalidArgument, + Protocols::SecureChannel::Id, Protocols::SecureChannel::kProtocolCodeGeneralFailure); err = CHIP_NO_ERROR; } return err;