You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unit Converter: Fahrenheit input bypasses absolute-zero validation and yields negative Kelvin #11103
public/Unit-Converter/script.js validates below-absolute-zero inputs only when the source unit is Kelvin or Celsius. Selecting Fahrenheit as the source unit skips both guards entirely, so physically impossible temperatures convert successfully into negative Kelvin - contradicting the validation the same form enforces for the other two units.
Static-analysis finding based on reading branch Main; not executed here.
Location
File: public/Unit-Converter/script.js
Functions: validateInput() (guards at ~lines 303-325) and convertTemperature() (~lines 349-371)
if(fromUnit.value==="kelvin"&&value<0){return{valid:false,message:"Temperature cannot be below 0 Kelvin"};}if(fromUnit.value==="celsius"&&value<-273.15){return{valid:false,message:"Temperature cannot be below -273.15 C"};}
There is no corresponding guard for fromUnit.value==="fahrenheit" (-459.67 F = absolute zero), while convertTemperature() processes any Fahrenheit value ((value-32)*5/9, then +273.15 for Kelvin output).
Trigger / Reproduction
Based on source reading:
Category: Temperature, From: Fahrenheit, To: Kelvin.
Enter -500 (the input filter allows -).
Validation passes (no Fahrenheit branch).
Output: (-500-32)*5/9 + 273.15 = -22.41 K.
Expected Behavior
The same physical state must be rejected regardless of source unit: entering -22 K directly shows "Temperature cannot be below 0 Kelvin", so converting to that identical value from Fahrenheit should be rejected too.
Actual Behavior
A negative Kelvin result is displayed as a successful conversion.
Impact
The converter's core purpose (physically valid conversions) silently breaks for one of its three supported units; users receive impossible values with no warning.
Suggested Direction
Convert the input to Kelvin first inside validateInput() (or add the missing Fahrenheit guard < -459.67) so the physical limit is enforced once for all units instead of per-unit in the input scale.
I'd like to take this up - requesting assignment per GSSoC'26 first-come-first-serve guidelines (@Poojax21).
Thank you for raising this issue! We'll look into it as soon as possible. Please ensure that the issue is not duplicate, and you read CONTRIBUTING.md carefully. Your contributions are highly appreciated! 😊
Activity
github-actions commentedon Aug 26, 2026
Thank you for raising this issue! We'll look into it as soon as possible. Please ensure that the issue is not duplicate, and you read CONTRIBUTING.md carefully. Your contributions are highly appreciated! 😊