3.6 KiB
3.6 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | |
|---|---|---|---|---|---|---|---|---|
| config/validation | Implement config validation with all 18 validation rules and error reporting | completed |
|
moderate | medium | component | implementation |
Description
Implement comprehensive config validation per the 18 rules defined in config.md. Validation runs on startup (fail-fast, exit with non-zero code) and on reload (reject reload, log error).
Validation Rules (from config.md)
- At least one
[[listeners]]entry must exist - Each listener's
bind_addris not0.0.0.0unlessallow_wildcard_bindis enabled (config OR CLI flag — OR relationship) - Each listener's
bind_addrandhttps_portcombination must be unique - In ACME mode,
acme_domainsmust be non-empty - In manual mode,
cert_pathandkey_pathmust both be set and files must be readable - Each site must have a
hostandupstream - Site
hostvalues must be unique across all listeners (no duplicate hostnames) rate_limit.requests_per_secondmust be > 0body.limit_bytesmust be > 0- Each listener's
bind_addrandhttp_portcombination must be unique (if http_port > 0) - Within a listener,
http_portandhttps_portmust differ https_portmust be 1–65535 (required — TLS needs a port)http_portmust be 0 (disabled) or 1–65535health_check_portmust not conflict with any listener'shttp_portorhttps_porton the same bind address- Site
hostvalues must not include a port number (e.g.,git.alk.dev, notgit.alk.dev:443) - Site
hostvalues must be valid hostnames (not IP addresses, not including ports). Hostnames normalized to lowercase upstreammust be inhost:portformat whereportis 1–65535upstream_schemevalues must be"http"or"https"(lowercase)
Error Reporting
On validation failure, collect ALL errors (don't stop at first) and report them together. This helps operators fix multiple issues in one pass. Use a Vec<ValidationError> that is logged or printed on startup failure.
Startup vs Reload Behavior
- Startup: If validation fails, exit with non-zero code and log all validation errors
- Reload: If validation fails, reject the reload, log all errors, keep old DynamicConfig active
Acceptance Criteria
- All 18 validation rules implemented
- Validation collects all errors (doesn't stop at first)
ValidationErrorenum with descriptive messages for each rulevalidate(config: &StaticConfig, dynamic: &DynamicConfig) -> Result<(), Vec<ValidationError>>function- Startup validation: exits with code 1 on failure, logs all errors
- Reload validation: rejects reload on failure, logs all errors, keeps old config
allow_wildcard_bindOR logic: config flag OR CLI flag enables it- Hostname normalization to lowercase during validation
- File existence check for manual mode
cert_pathandkey_path - Unit tests covering each validation rule with valid and invalid inputs
- Integration test: valid config from config.md examples passes all validation
References
- docs/architecture/config.md — full validation rules, default values, TOML format
- docs/architecture/decisions/016-explicit-bind-address.md —
0.0.0.0rejection rationale - docs/architecture/decisions/020-container-deployment.md —
allow_wildcard_bindfor containers
Notes
Rule 5 (file readability check for manual certs) should check that the files exist and are readable at validation time, not just that the paths are set. This provides early feedback on misconfiguration.
Summary
To be filled on completion