Problem
In src/services/config-service.ts the get() method falls back to environment variables when a key is absent from the cache and the database. The numeric-coercion branch has an off-by-one:
// config-service.ts ~line 333
if (!isNaN(Number(envValue))) {
const numValue = Number(envValue);
this.cache.set(key, numValue);
return numValue;
}
Number("") evaluates to 0, and isNaN(0) is false. So any env var that is set to an empty string is cached as the number 0 instead of being treated as absent. This bypasses every defaultValue argument callers pass to getNumber() and getBoolean().
Reproduction scenario
- An operator sets
SOME_KEY= (empty value) in their .env — possibly a leftover placeholder.
configService.getNumber("SOME_KEY", 60) silently returns 0 instead of 60.
- Features depending on that number (cooldowns, max lengths, retention periods, etc.) behave with a value of
0, which can mean "unlimited" or "zero seconds" depending on the callsite.
Suggested fix
Guard with an explicit emptiness check before trying numeric conversion:
const envValue = process.env[key];
if (envValue !== undefined && envValue.trim() !== "") {
if (envValue === "true" || envValue === "false") {
const boolValue = envValue === "true";
this.cache.set(key, boolValue);
return boolValue;
}
const numValue = Number(envValue);
if (!isNaN(numValue)) {
this.cache.set(key, numValue);
return numValue;
}
this.cache.set(key, envValue);
return envValue;
}
This makes an empty env var behave as if the key were absent, so defaultValue arguments are correctly honoured.
Affected file
src/services/config-service.ts lines 326–341 (the env-var fallback branch inside get())
Problem
In
src/services/config-service.tstheget()method falls back to environment variables when a key is absent from the cache and the database. The numeric-coercion branch has an off-by-one:Number("")evaluates to0, andisNaN(0)isfalse. So any env var that is set to an empty string is cached as the number0instead of being treated as absent. This bypasses everydefaultValueargument callers pass togetNumber()andgetBoolean().Reproduction scenario
SOME_KEY=(empty value) in their.env— possibly a leftover placeholder.configService.getNumber("SOME_KEY", 60)silently returns0instead of60.0, which can mean "unlimited" or "zero seconds" depending on the callsite.Suggested fix
Guard with an explicit emptiness check before trying numeric conversion:
This makes an empty env var behave as if the key were absent, so
defaultValuearguments are correctly honoured.Affected file
src/services/config-service.tslines 326–341 (the env-var fallback branch insideget())