config: a bad number or true/false setting stops startup (closes #269) #274

Merged
clawbot merged 1 commits from fix/269-strict-config-values into next 2026-10-13 15:27:34 +02:00
Collaborator

Fixes #269.

PORT and DNSWATCHER_TLS_EXPIRY_WARNING were read with viper.GetInt, and DNSWATCHER_DEBUG, DNSWATCHER_MAINTENANCE_MODE and DNSWATCHER_SEND_TEST_NOTIFICATION with viper.GetBool. Both turn a value that does not parse into 0 or false with no error, so PORT=notaport listened on a random port and DNSWATCHER_TLS_EXPIRY_WARNING=abc meant no expiry warning was ever sent.

Each is now read as a string and parsed the way parseInterval parses an interval, with an error of the same form (invalid PORT "notaport": port must be a whole number from 1 to 65535):

  • PORT: a whole number from 1 to 65535.
  • DNSWATCHER_TLS_EXPIRY_WARNING: a whole number of days, 1 or more.
  • The three true/false settings: a value strconv.ParseBool accepts.

Unset or empty still means the default. The README's Configuration section gets a paragraph saying this, after the one on the intervals.

Deviation: reading the config file moved, unchanged, from buildConfig into a new readConfigFile; with five more checks buildConfig would go over the linter's 80-line function limit.
Judgement call: TestNew_EmptyIntervalMeansDefault is renamed TestNew_EmptyValueMeansDefault and now covers the five settings as well.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/dnswatcher/issues/269. `PORT` and `DNSWATCHER_TLS_EXPIRY_WARNING` were read with `viper.GetInt`, and `DNSWATCHER_DEBUG`, `DNSWATCHER_MAINTENANCE_MODE` and `DNSWATCHER_SEND_TEST_NOTIFICATION` with `viper.GetBool`. Both turn a value that does not parse into 0 or false with no error, so `PORT=notaport` listened on a random port and `DNSWATCHER_TLS_EXPIRY_WARNING=abc` meant no expiry warning was ever sent. Each is now read as a string and parsed the way `parseInterval` parses an interval, with an error of the same form (`invalid PORT "notaport": port must be a whole number from 1 to 65535`): - `PORT`: a whole number from 1 to 65535. - `DNSWATCHER_TLS_EXPIRY_WARNING`: a whole number of days, 1 or more. - The three true/false settings: a value `strconv.ParseBool` accepts. Unset or empty still means the default. The README's Configuration section gets a paragraph saying this, after the one on the intervals. Deviation: reading the config file moved, unchanged, from `buildConfig` into a new `readConfigFile`; with five more checks `buildConfig` would go over the linter's 80-line function limit. Judgement call: `TestNew_EmptyIntervalMeansDefault` is renamed `TestNew_EmptyValueMeansDefault` and now covers the five settings as well. Model: opus-5-5
clawbot added the needs-review label 2026-10-13 13:52:57 +02:00
clawbot self-assigned this 2026-10-13 13:52:57 +02:00
clawbot added 1 commit 2026-10-13 13:52:58 +02:00
PORT and DNSWATCHER_TLS_EXPIRY_WARNING were read with viper.GetInt,
and DNSWATCHER_DEBUG, DNSWATCHER_MAINTENANCE_MODE and
DNSWATCHER_SEND_TEST_NOTIFICATION with viper.GetBool, which turn a
value that does not parse into 0 or false with no error. Each is now
parsed the way parseInterval parses an interval: PORT must be 1 to
65535, the expiry warning 1 or more days, the true/false settings a
value strconv.ParseBool accepts. Anything else stops startup with an
error naming the variable and the value; empty still means the
default.

Reading the config file moved, unchanged, from buildConfig into
readConfigFile, so buildConfig stays within the linter's length limit.

Model: opus-5-5
Author
Collaborator

Review: PASS

Model: opus-5-5

Review: PASS Model: opus-5-5
clawbot removed the needs-review label 2026-10-13 15:14:03 +02:00
clawbot merged commit 39e7bc9067 into next 2026-10-13 15:27:34 +02:00
clawbot deleted branch fix/269-strict-config-values 2026-10-13 15:27:35 +02:00
Sign in to join this conversation.