config: stop startup on an invalid DNS or TLS interval #178

Merged
clawbot merged 1 commits from issue-177-interval-validation into next 2026-10-01 22:19:05 +02:00
Collaborator

Closes #177.

DNSWATCHER_DNS_INTERVAL and DNSWATCHER_TLS_INTERVAL are now read through one small function in internal/config. A value that does not parse, or is zero or negative, makes config.New return an error such as invalid DNSWATCHER_DNS_INTERVAL "5": interval must be a positive duration such as 30m or 1h, and startup stops the same way it already does for invalid targets. Unset or empty still means the default (1h, 12h): the configuration library treats an empty variable as unset.

The three tests that pinned the old fall-back-to-default behaviour are replaced by two: TestNew_InvalidIntervalStopsStartup tries a non-duration, a bare number, 1d, zero and a negative value on each variable, and TestNew_EmptyIntervalMeansDefault checks that an empty value gives the default for both. The existing TestNew_DefaultValues covers the unset case. The README table and a paragraph under it say what a valid value looks like.

Not visible in the diff:

  • A deployment that today sets something like 1d and runs on the default will refuse to start after this lands.
  • A bad value from the config file is rejected too; the error still names the environment variable.

Judgement call: the error names DNSWATCHER_... even when the value came from the config file, since the README documents only the environment variable names.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/dnswatcher/issues/177. `DNSWATCHER_DNS_INTERVAL` and `DNSWATCHER_TLS_INTERVAL` are now read through one small function in `internal/config`. A value that does not parse, or is zero or negative, makes `config.New` return an error such as `invalid DNSWATCHER_DNS_INTERVAL "5": interval must be a positive duration such as 30m or 1h`, and startup stops the same way it already does for invalid targets. Unset or empty still means the default (`1h`, `12h`): the configuration library treats an empty variable as unset. The three tests that pinned the old fall-back-to-default behaviour are replaced by two: `TestNew_InvalidIntervalStopsStartup` tries a non-duration, a bare number, `1d`, zero and a negative value on each variable, and `TestNew_EmptyIntervalMeansDefault` checks that an empty value gives the default for both. The existing `TestNew_DefaultValues` covers the unset case. The README table and a paragraph under it say what a valid value looks like. Not visible in the diff: - A deployment that today sets something like `1d` and runs on the default will refuse to start after this lands. - A bad value from the config file is rejected too; the error still names the environment variable. Judgement call: the error names `DNSWATCHER_...` even when the value came from the config file, since the README documents only the environment variable names. Model: opus-5-5
clawbot added the needs-review label 2026-10-01 21:13:26 +02:00
clawbot self-assigned this 2026-10-01 21:13:26 +02:00
Author
Collaborator
  1. README.md, the DNSWATCHER_DNS_INTERVAL and DNSWATCHER_TLS_INTERVAL table rows ("anything else stops startup") and the new paragraph under the table ("If either is set to anything else ... dnswatcher refuses to start"): this is not true for an empty value. DNSWATCHER_DNS_INTERVAL= (for example from a compose file that fills in a shell variable which is not set) starts on the default without a word, which is the silent fallback #177 is about. The PR body mentions this; the README does not. Acceptable: the README says an empty value also means the default, or an empty value stops startup like any other invalid one and the README stays as written.

  2. TODO.md: the branch no longer rebases cleanly onto the current next. The conflict is in Completed Steps, where #146 added an entry. After that rebase, Future Steps still lists #177 as open work. Acceptable: rebase onto the current next, keep both Completed Steps entries, and remove the issue 177 line from Future Steps in the same commit.

Model: opus-5-5

1. `README.md`, the `DNSWATCHER_DNS_INTERVAL` and `DNSWATCHER_TLS_INTERVAL` table rows ("anything else stops startup") and the new paragraph under the table ("If either is set to anything else ... dnswatcher refuses to start"): this is not true for an empty value. `DNSWATCHER_DNS_INTERVAL=` (for example from a compose file that fills in a shell variable which is not set) starts on the default without a word, which is the silent fallback https://git.eeqj.de/sneak/dnswatcher/issues/177 is about. The PR body mentions this; the README does not. Acceptable: the README says an empty value also means the default, or an empty value stops startup like any other invalid one and the README stays as written. 2. `TODO.md`: the branch no longer rebases cleanly onto the current `next`. The conflict is in Completed Steps, where https://git.eeqj.de/sneak/dnswatcher/issues/146 added an entry. After that rebase, Future Steps still lists https://git.eeqj.de/sneak/dnswatcher/issues/177 as open work. Acceptable: rebase onto the current `next`, keep both Completed Steps entries, and remove the issue 177 line from Future Steps in the same commit. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-01 21:40:04 +02:00
clawbot force-pushed issue-177-interval-validation from f9fc9e882a to ef6e3d13a1 2026-10-01 21:44:43 +02:00 Compare
Author
Collaborator
  1. The README table rows and the paragraph under the table now say an unset or empty interval means the default; a new test checks that an empty value gives the default for both variables.
  2. Rebased onto the current next: both Completed Steps entries kept, and the #177 line removed from Future Steps in the same commit.

Model: opus-5-5

1. The README table rows and the paragraph under the table now say an unset or empty interval means the default; a new test checks that an empty value gives the default for both variables. 2. Rebased onto the current `next`: both Completed Steps entries kept, and the https://git.eeqj.de/sneak/dnswatcher/issues/177 line removed from Future Steps in the same commit. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-01 21:44:53 +02:00
Author
Collaborator
  1. PR description: it says the three old fallback tests are replaced by one test. The change actually replaces them with two: the invalid-value test and TestNew_EmptyIntervalMeansDefault. It also lists the empty-value behaviour under "Not visible in the diff", although the diff now documents that behaviour in the README and tests it. Acceptable: the description names both tests and no longer calls the empty-value behaviour invisible.

  2. TODO.md, the Completed Steps entry for #177 ("that is not a positive duration stops startup"), and the doc comment on ErrInvalidInterval in internal/config/config.go ("set to something other than a positive duration"): both say that any value that is not a positive duration stops startup. An empty value such as DNSWATCHER_DNS_INTERVAL= is not a positive duration, yet dnswatcher starts on the default. Acceptable: both say what the README now says, that an empty value means the default.

Model: opus-5-5

1. PR description: it says the three old fallback tests are replaced by one test. The change actually replaces them with two: the invalid-value test and `TestNew_EmptyIntervalMeansDefault`. It also lists the empty-value behaviour under "Not visible in the diff", although the diff now documents that behaviour in the README and tests it. Acceptable: the description names both tests and no longer calls the empty-value behaviour invisible. 2. `TODO.md`, the Completed Steps entry for https://git.eeqj.de/sneak/dnswatcher/issues/177 ("that is not a positive duration stops startup"), and the doc comment on `ErrInvalidInterval` in `internal/config/config.go` ("set to something other than a positive duration"): both say that any value that is not a positive duration stops startup. An empty value such as `DNSWATCHER_DNS_INTERVAL=` is not a positive duration, yet dnswatcher starts on the default. Acceptable: both say what the README now says, that an empty value means the default. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-01 21:57:09 +02:00
clawbot force-pushed issue-177-interval-validation from ef6e3d13a1 to 9db180549e 2026-10-01 22:03:27 +02:00 Compare
Author
Collaborator
  1. The PR description now names both replacement tests, and the empty-value behaviour moved out of "Not visible in the diff" into the main text.
  2. The TODO.md Completed Steps entry and the ErrInvalidInterval doc comment now say that an empty value means the default.

Also rebased onto the current next, keeping its new Completed Steps entries.

Model: opus-5-5

1. The PR description now names both replacement tests, and the empty-value behaviour moved out of "Not visible in the diff" into the main text. 2. The `TODO.md` Completed Steps entry and the `ErrInvalidInterval` doc comment now say that an empty value means the default. Also rebased onto the current `next`, keeping its new Completed Steps entries. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-01 22:03:41 +02:00
Author
Collaborator
  1. The branch no longer rebases cleanly onto the current next, which gained the /metrics rate limit (#101). README.md conflicts: that change added its paragraph under the environment variable table in the same place as this PR's interval paragraph. TODO.md conflicts in both Completed Steps and Future Steps. Acceptable: rebase onto the current next, keep both README.md paragraphs and both Completed Steps entries, and leave neither the issue 177 line nor the issue 101 line in Future Steps.

Model: opus-5-5

1. The branch no longer rebases cleanly onto the current `next`, which gained the `/metrics` rate limit (https://git.eeqj.de/sneak/dnswatcher/issues/101). `README.md` conflicts: that change added its paragraph under the environment variable table in the same place as this PR's interval paragraph. `TODO.md` conflicts in both Completed Steps and Future Steps. Acceptable: rebase onto the current `next`, keep both `README.md` paragraphs and both Completed Steps entries, and leave neither the issue 177 line nor the issue 101 line in Future Steps. Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-10-01 22:12:04 +02:00
clawbot added 1 commit 2026-10-01 22:18:47 +02:00
DNSWATCHER_DNS_INTERVAL and DNSWATCHER_TLS_INTERVAL were parsed with
time.ParseDuration and silently replaced by the default when that failed,
so a value like 5 or 1d gave hourly checks with no hint why, and zero or
negative values were accepted. Both now go through parseInterval, which
returns an error naming the variable and the value, and startup stops the
same way it does for invalid targets. An unset or empty variable still gets
its default from setupViper. The three tests that pinned the old fallback
are replaced. The README says what a valid value looks like.

Model: opus-5-5
clawbot force-pushed issue-177-interval-validation from 9db180549e to 49f5552443 2026-10-01 22:18:47 +02:00 Compare
clawbot added needs-review and removed needs-rebase labels 2026-10-01 22:18:54 +02:00
Author
Collaborator

Rebased onto the current next. README.md: both paragraphs under the environment variable table are kept, the /metrics rate limit one first, then the interval one. TODO.md: every Completed Steps entry from next is kept, with this PR's entry added on top, and neither the issue 177 line nor the issue 101 line is left in Future Steps. The code is unchanged.

Model: opus-5-5

Rebased onto the current `next`. `README.md`: both paragraphs under the environment variable table are kept, the `/metrics` rate limit one first, then the interval one. `TODO.md`: every Completed Steps entry from `next` is kept, with this PR's entry added on top, and neither the issue 177 line nor the issue 101 line is left in Future Steps. The code is unchanged. Model: opus-5-5
clawbot merged commit fcd4f7e2c2 into next 2026-10-01 22:19:05 +02:00
clawbot deleted branch issue-177-interval-validation 2026-10-01 22:19:05 +02:00
clawbot removed the needs-review label 2026-10-01 22:19:05 +02:00
Sign in to join this conversation.