In the GetWeather.js
script used by Chainlink Functions is responsible for converting weather data from the OpenWeather API into an integer enum value representing the weather condition (e.g., SUNNY, RAINY, CLOUDY, etc.).
The script uses weather_id === 800 to classify clear weather and parseInt(weather_id / 100) === 8 to classify clouds. However, since 800 satisfies both conditions, the second conditional overwrites the first, causing clear weather to be misclassified as cloudy.
Likelihood:
This occurs whenever the weather condition ID from OpenWeather is exactly 800, which is very common (indicating clear skies).
The conditions are ordered such that the broader check (weather_id_x === 8) overrides the exact match for clear skies.
Impact:
Incorrect weather classification leads to wrong NFT metadata and user-facing weather state.
The image URI, NFT logic, and automation tied to weather enum become inconsistent or misleading.
Here is a test code which stimulates the response form OpenWeather
This guarantees that 800 is uniquely classified as SUNNY, and other 80x values (like 801, 802, 803, 804) correctly fall under CLOUDY
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.