A setting that is not a valid number or true/false is read as 0 or false instead of stopping startup #269

Closed
opened 2026-10-13 12:50:07 +02:00 by clawbot · 0 comments
Collaborator

Found in the trial run for #260, on next at e8b4006.

buildConfig in internal/config/config.go reads PORT and DNSWATCHER_TLS_EXPIRY_WARNING with viper.GetInt, and DNSWATCHER_DEBUG, DNSWATCHER_MAINTENANCE_MODE and DNSWATCHER_SEND_TEST_NOTIFICATION with viper.GetBool. A value that does not parse becomes 0 or false, and dnswatcher starts with no error and nothing logged:

  • DNSWATCHER_TLS_EXPIRY_WARNING=abc, or -5, gives a warning period of 0 days, so no expiry warning is ever sent: a certificate would be warned about only after it expired, and an expired one fails the TLS check instead.
  • PORT=notaport starts the HTTP server on a random port ("addr":":0" in the log). The dashboard, the API and the image's HEALTHCHECK cannot reach it.
  • DNSWATCHER_MAINTENANCE_MODE=yes reports "maintenanceMode":false; DNSWATCHER_SEND_TEST_NOTIFICATION=yes sends no test notification.

The interval settings already stop startup on a bad value, naming the variable and the value (README, Configuration). These five should do the same.

Done when:

  • PORT must be a whole number from 1 to 65535, and DNSWATCHER_TLS_EXPIRY_WARNING a whole number of days, 1 or more. DNSWATCHER_DEBUG, DNSWATCHER_MAINTENANCE_MODE and DNSWATCHER_SEND_TEST_NOTIFICATION take a value Go's strconv.ParseBool accepts. Anything else stops startup with an error naming the variable and the value. Unset or empty still means the default.
  • Tests in internal/config cover a bad value and a good one for each.
  • The README's Configuration section says this, as its paragraph on the intervals does.

Severity: major

Model: opus-5-5

Found in the trial run for https://git.eeqj.de/sneak/dnswatcher/issues/260, on `next` at `e8b4006`. `buildConfig` in `internal/config/config.go` reads `PORT` and `DNSWATCHER_TLS_EXPIRY_WARNING` with `viper.GetInt`, and `DNSWATCHER_DEBUG`, `DNSWATCHER_MAINTENANCE_MODE` and `DNSWATCHER_SEND_TEST_NOTIFICATION` with `viper.GetBool`. A value that does not parse becomes 0 or false, and dnswatcher starts with no error and nothing logged: - `DNSWATCHER_TLS_EXPIRY_WARNING=abc`, or `-5`, gives a warning period of 0 days, so no expiry warning is ever sent: a certificate would be warned about only after it expired, and an expired one fails the TLS check instead. - `PORT=notaport` starts the HTTP server on a random port (`"addr":":0"` in the log). The dashboard, the API and the image's `HEALTHCHECK` cannot reach it. - `DNSWATCHER_MAINTENANCE_MODE=yes` reports `"maintenanceMode":false`; `DNSWATCHER_SEND_TEST_NOTIFICATION=yes` sends no test notification. The interval settings already stop startup on a bad value, naming the variable and the value (README, Configuration). These five should do the same. Done when: - `PORT` must be a whole number from 1 to 65535, and `DNSWATCHER_TLS_EXPIRY_WARNING` a whole number of days, 1 or more. `DNSWATCHER_DEBUG`, `DNSWATCHER_MAINTENANCE_MODE` and `DNSWATCHER_SEND_TEST_NOTIFICATION` take a value Go's `strconv.ParseBool` accepts. Anything else stops startup with an error naming the variable and the value. Unset or empty still means the default. - Tests in `internal/config` cover a bad value and a good one for each. - The README's Configuration section says this, as its paragraph on the intervals does. Severity: major Model: opus-5-5
clawbot added this to the 1.0 milestone 2026-10-13 12:50:07 +02:00
clawbot self-assigned this 2026-10-13 12:50:07 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/dnswatcher#269