Functions WeatherNft::fulfillMintRequest and WeatherNft::_fulfillWeatherUpdate empty return after Chainlink Function response check.
Description:
WeatherNft::fulfillMintRequest and WeatherNft::_fulfillWeatherUpdate make checks on the response length and the error message length and if a issue is find, return the function without give any reason.
On WeatherNft::fulfillMintRequest:
function fulfillMintRequest(bytes32 requestId) external {
require(msg.sender == s_reqIdToUser[requestId], "Invalid user");
bytes memory response = s_funcReqIdToMintFunctionReqResponse[requestId].response;
bytes memory err = s_funcReqIdToMintFunctionReqResponse[requestId].err;
require(response.length > 0 || err.length > 0, WeatherNft__Unauthorized());
@> if (response.length == 0 || err.length > 0) {
@> return;
@> }
UserMintRequest memory _userMintRequest = s_funcReqIdToUserMintReq[requestId];
.
.
On WeatherNft::_fulfillWeatherUpdate:
function _fulfillWeatherUpdate(bytes32 requestId, bytes memory response, bytes memory err) internal {
@> if (response.length == 0 || err.length > 0) {
@> return;
@> }
uint256 tokenId = s_funcReqIdToTokenIdUpdate[requestId];
.
.
Impact:
The user never knows what issue in the Chainlin Function response cause the return
Recommended Mitigation:
Return the consice issue.
On WeatherNft::fulfillMintRequest:
function fulfillMintRequest(bytes32 requestId) external {
require(msg.sender == s_reqIdToUser[requestId], "Invalid user");
bytes memory response = s_funcReqIdToMintFunctionReqResponse[requestId].response;
bytes memory err = s_funcReqIdToMintFunctionReqResponse[requestId].err;
require(response.length > 0 || err.length > 0, WeatherNft__Unauthorized());
- if (response.length == 0 || err.length > 0) {
- return;
- }
+ if (response.length == 0) {
+ require(false, "Response Empty");
+ } else if (err.length > 0) {
+ require(false, string(err));
+ }
UserMintRequest memory _userMintRequest = s_funcReqIdToUserMintReq[requestId];
.
.
On WeatherNft::_fulfillWeatherUpdate:
function _fulfillWeatherUpdate(bytes32 requestId, bytes memory response, bytes memory err) internal {
- if (response.length == 0 || err.length > 0) {
- return;
- }
+ if (response.length == 0) {
+ require(false, "Response Empty");
+ } else if (err.length > 0) {
+ require(false, string(err));
+ }
uint256 tokenId = s_funcReqIdToTokenIdUpdate[requestId];
.
.