Summary
assets/observer.mjs converts OBSERVER_PORT with a bare Number() call. If the environment variable is set to a non-numeric value, PORT becomes NaN and server.listen(NaN, ...) silently binds to a random ephemeral port rather than throwing — the Observer appears to start but is unreachable on the expected port.
Category
Bug
Severity
Low
Details
// assets/observer.mjs:9
const PORT = Number(process.env.OBSERVER_PORT || 4317);
Number('bad-value') returns NaN. Node's server.listen(NaN) does not throw; it picks an OS-assigned port, so the dashboard is no longer at the printed URL. The entry script sets OBSERVER_PORT from config.observerPort which is already validated by the CLI, but direct invocations (e.g. running observer.mjs outside of agentbox) are unprotected.
Suggested Fix
Add a guard after the Number() call:
const PORT = Number(process.env.OBSERVER_PORT || 4317);
if (!Number.isInteger(PORT) || PORT < 1 || PORT > 65535) {
console.error(`[observer] Invalid OBSERVER_PORT: ${process.env.OBSERVER_PORT}`);
process.exit(1);
}
Effort Estimate
5 min
Automated finding by repo-health-agent v1.0
Summary
assets/observer.mjsconvertsOBSERVER_PORTwith a bareNumber()call. If the environment variable is set to a non-numeric value,PORTbecomesNaNandserver.listen(NaN, ...)silently binds to a random ephemeral port rather than throwing — the Observer appears to start but is unreachable on the expected port.Category
Bug
Severity
Low
Details
Number('bad-value')returnsNaN. Node'sserver.listen(NaN)does not throw; it picks an OS-assigned port, so the dashboard is no longer at the printed URL. The entry script setsOBSERVER_PORTfromconfig.observerPortwhich is already validated by the CLI, but direct invocations (e.g. runningobserver.mjsoutside of agentbox) are unprotected.Suggested Fix
Add a guard after the
Number()call:Effort Estimate
5 min
Automated finding by repo-health-agent v1.0