config: fail fast when DNSWATCHER_TARGETS is empty #77

Closed
clawbot wants to merge 1 commits from fix/empty-targets-validation into main
Collaborator

When DNSWATCHER_TARGETS is empty or unset (the default), dnswatcher now exits with a clear error message instead of silently starting with nothing to monitor.

Changes

  • Added ErrNoTargets sentinel error in internal/config/config.go
  • buildConfig now validates that at least one domain or hostname is configured after target classification
  • When no targets are configured, config.New returns ErrNoTargets, causing the fx application to fail to start with a clear error message
  • Extracted classifyAndValidateTargets() and parseDurationOrDefault() helpers to keep buildConfig within the funlen limit
  • Added tests: TestNewReturnsErrNoTargetsWhenEmpty and TestNewSucceedsWithTargets

Closes #69

When `DNSWATCHER_TARGETS` is empty or unset (the default), dnswatcher now exits with a clear error message instead of silently starting with nothing to monitor. ## Changes - Added `ErrNoTargets` sentinel error in `internal/config/config.go` - `buildConfig` now validates that at least one domain or hostname is configured after target classification - When no targets are configured, `config.New` returns `ErrNoTargets`, causing the fx application to fail to start with a clear error message - Extracted `classifyAndValidateTargets()` and `parseDurationOrDefault()` helpers to keep `buildConfig` within the funlen limit - Added tests: `TestNewReturnsErrNoTargetsWhenEmpty` and `TestNewSucceedsWithTargets` Closes #69
clawbot added 1 commit 2026-03-02 01:22:40 +01:00
config: fail fast when DNSWATCHER_TARGETS is empty
All checks were successful
check / check (push) Successful in 45s
713a2b7332
When DNSWATCHER_TARGETS is empty or unset (the default), dnswatcher now
exits with a clear error message instead of silently starting with
nothing to monitor.

Added ErrNoTargets sentinel error returned from config.New when both
domains and hostnames lists are empty after target classification. This
causes the fx application to fail to start, preventing silent
misconfiguration.

Also extracted classifyAndValidateTargets and parseDurationOrDefault
helper functions to keep buildConfig within the funlen limit.

Closes #69
clawbot added the bot label 2026-03-02 01:22:46 +01:00
Author
Collaborator

Closing as duplicate — PR #75 already addresses issue #69 and is merge-ready.

Closing as duplicate — PR #75 already addresses issue #69 and is merge-ready.
clawbot closed this pull request 2026-03-02 01:22:50 +01:00
clawbot added the needs-review label 2026-03-02 01:22:52 +01:00
All checks were successful
check / check (push) Successful in 45s
Required
Details

Pull request closed

Sign in to join this conversation.