Skip to content

fix(common,node,cli): route config-resolve notices to the log stream (#1902) - #1915

Merged
thiras merged 3 commits into
mainfrom
fix/1902-config-notices-log-stream
Sep 2, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/1902-config-notices-log-stream

Conversation

@thiras

@thiras thiras commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Closes #1902

The problem

resolve_security_into emits its operator warnings with eprintln!, documented as load-bearing because no tracing subscriber exists at resolve_config time. That reasoning holds for startup. It does not hold for the function's second caller, runtime::reload::SecuritySection::resolve, which runs on SIGHUP against a daemon whose subscriber has been live for hours.

Concretely: an operator running log_format = "json" and shipping only the structured stream sets security.max_tracked_sources = 0 and SIGHUPs. The "rate-limit bookkeeping map is unbounded" warning goes to a raw stderr nobody is reading. infallible_swap does emit an event carrying the new value, but at info level and without the word "unbounded", so nothing alerts on it.

The fix

The mechanism already existed and was half-built: warn_retired_env_vars returns the names it warned about specifically so a caller can propagate them, and resolve_config discarded the value into _retired.

Resolvers now record ConfigNotices on the shared bag. That bag is already threaded by &mut through every *_into worker at startup and through every reloadable section on SIGHUP (ReloadableSection::resolve(&self, file, bag)), so the reload path is covered with zero signature changes to the trait or to any resolver. The caller renders them, because the caller is the only layer that knows which sink it has:

Path Renders as
decdn-node startup tracing events, right after init_tracing
SIGHUP / admin_v1_reload tracing events, on the success path only
decdn config validate a notices (N): block under the field summary
decdn node doctor findings

The last two matter because crates/cli has no tracing dependency at all — the other half of why eprintln! was chosen. Returning notices is what makes those paths renderable.

Nothing became a hard error: 0 = unbounded is a documented escape hatch and an inherited orchestrator env var must not refuse boot. The problem was reachability, not severity.

Scope

All ten former eprintln! statements convert, not just the one on the reload path — resolve_network_into's --relay-url notice has the same reachability gap at startup, and a stale DECDN_RELAY_URL collapsing a multi-entry failover list to one entry is a silent redundancy loss that reads as an unexplained outage months later.

Function Field(s) Level
warn_retired_env_vars_with the env var name Warn
validate_port_layout_into network.bind_port, observability.metrics_port, observability.admin_port Warn
resolve_network_into network.relay_url Warn
resolve_security_into .max_concurrent_handlers, .per_source_rate_per_sec Info
resolve_security_into security.max_tracked_sources Warn
resolve_dht_into dht.rate_limit.max_tracked_per_{ip,peer} Warn
resolve_probe_into probe.rate_limit.max_tracked_per_{ip,peer} Warn

The severity split is the operator's, not the resolver's: an unbounded bookkeeping map moves doctor's exit status, a deliberately disabled rate limit does not.

Notable

  • ConfigErrorBag → ConfigDiagnostics. It carries both channels now, and bag.warn(…) on a type named …ErrorBag reads wrong. Mechanical; the only user outside decdn-common is runtime/reload.rs.
  • resolve_config returns (ResolvedConfig, Vec<ConfigNotice>). Per the pre-launch rule, the signature changes rather than gaining a _with_notices sibling.
  • Notices are dropped on the error path, in both resolve_config and reload. A config that does not resolve is not the one the operator is running, so its notices would describe nothing live. The SIGHUP test pins this.
  • emit_config_notices lives in runtime/reload.rs beside warn_ignored / warn_restart_required_sections, shared with commands::run.
  • init_tracing could not simply move above resolve_config: its fallback EnvFilter is built from resolved.observability.log_level. Deferring the emit is the fix.

Testing

  • SIGHUP regression guard in sighup_signal.rs, reusing that file's capture harness (thread-local set_default, current_thread runtime, reload awaited inline — the three constraints its doc spells out). Asserts the notice reaches the buffer at WARN carrying "unbounded", and that an aborted reload emits nothing.
  • A unit test per converted site asserting field, level, and message. This is strictly new coverage: mod.rs previously described these as "other untested eprintln! resolve warnings", and the resolve_security tests hit the == 0 branches without asserting anything about them.
  • errors.rs: notices alone don't fail resolution; take_notices drains in insertion order and doesn't disturb the problem channel.
  • CLI: the summary renders notices and omits the block when there are none; doctor maps Warn→Warn and Info→Pass without moving exit status.

cargo nextest run --workspace: 3233 passed. clippy --all-targets, fmt --check, and cargo doc -D warnings clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GqvbhAgEkq1XQ9Dm8TvLsq

…1902)

Every `*_into` resolver wrote its non-fatal warnings with `eprintln!`, on
the documented grounds that no `tracing` subscriber exists at
`resolve_config` time. That holds for startup, but `resolve_security_into`
also runs on the SIGHUP reload path, against a daemon whose subscriber has
been live for hours. An operator on `log_format = "json"` who set
`security.max_tracked_sources = 0` and reloaded got the "bookkeeping map is
unbounded" warning on a stderr nobody was reading, and nothing in their log
pipeline — the reload's own "section applied" event carried the new value
but neither the severity nor the word to alert on.

The resolvers now record `ConfigNotice`s on the shared bag, which is already
threaded through every `*_into` worker at startup and through every
reloadable section on SIGHUP, so the reload path is covered with no change
to `ReloadableSection::resolve`. The caller renders them once it knows which
sink it has: `decdn-node` replays them right after `init_tracing`,
`RuntimeReloadState::reload` emits them on the success path only, `decdn
config validate` prints them under its field summary, and `decdn node
doctor` turns them into findings — the last of which matters because
`crates/cli` links no subscriber at all.

Nothing became a hard error. `0 = unbounded` stays a documented escape
hatch, and an inherited orchestrator env var must not refuse boot.

- All ten former `eprintln!` sites convert: the retired-env-var notice, the
  well-known-port notice, the #843 `--relay-url`-overrides-the-list notice,
  and the unbounded-map notices across `security`, `dht.rate_limit` and
  `probe.rate_limit`. Each is now asserted; previously the only thing a test
  could check was that the value resolved, which `mod.rs` said in as many
  words ("other untested `eprintln!` resolve warnings").
- `ConfigErrorBag` becomes `ConfigDiagnostics`: it carries both channels
  now, and `bag.warn(…)` on a type named `…ErrorBag` reads wrong.
- Notices carry a severity. An unbounded bookkeeping map or a collapsed
  relay-failover list is `Warn` and moves `doctor`'s exit status; a
  deliberately disabled rate limit is `Info` and does not.
- `warn_retired_env_vars` moves below the bag it now writes to, and its
  discarded `_retired` return — the half-built version of this mechanism —
  collapses into the one call.
- The SIGHUP regression guard reuses the `sighup_signal.rs` capture harness
  (thread-local `set_default`, `current_thread` runtime, reload awaited
  inline) and also pins the negative: an aborted reload emits no notices,
  because it applies nothing.

Closes #1902

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GqvbhAgEkq1XQ9Dm8TvLsq
Copilot AI lite review requested due to automatic review settings September 2, 2026 22:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change cleanly routes resolve-time diagnostics to appropriate sinks across startup/reload/CLI paths and is backed by targeted unit and SIGHUP regression tests, with only a minor doc-contract nit noted.

Pull request overview

This PR fixes operator-facing config warnings that were previously emitted via eprintln! during config resolution (and therefore missed on the daemon SIGHUP reload path and in CLI flows without tracing). It introduces a structured “notice” channel collected during resolution and rendered by whichever caller owns an appropriate sink (node logging, CLI output, doctor findings).

Changes:

  • Replace resolve-time eprintln! warnings/info messages with recorded ConfigNotices carried by a renamed ConfigDiagnostics accumulator.
  • Emit recorded notices to tracing after subscriber installation at node startup and on successful SIGHUP reloads.
  • Extend CLI config validate and node doctor to render the returned notices; add unit + SIGHUP regression tests to pin reachability and severity.
File summaries
File Description
crates/common/src/config/errors.rs Renames/extends the diagnostics accumulator to also store non-fatal ConfigNotices.
crates/common/src/config/mod.rs Records notices during resolution and returns them from resolve_config as (ResolvedConfig, Vec<ConfigNotice>).
crates/node/src/runtime/reload.rs Drains and emits notices only on successful reload; adds shared emit_config_notices.
crates/node/src/runtime/mod.rs Re-exports emit_config_notices for use by startup command wiring.
crates/node/src/commands/mod.rs Replays resolve-time notices via tracing immediately after init_tracing.
crates/node/tests/sighup_signal.rs Adds regression test asserting SIGHUP reload notices reach the log stream and are suppressed on aborted reload.
crates/cli/src/commands/config.rs Renders resolve notices under the validate summary, omitting the block when empty.
crates/cli/src/commands/doctor/config.rs Converts notices into doctor findings with severity mapping Warn→Warn and Info→Pass.
crates/cli/tests/config_validate.rs Adds coverage for validate-summary notice rendering and empty-notice behavior.
CHANGELOG.md Documents the behavioral change and scope of converted notice sites.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/common/src/config/errors.rs Resolved
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.77% (was 82.69%, ▲ +0.08%) — 74495/90003 lines

File Coverage Lines Δ
crates/cli/src/commands/config.rs 87.30% 811/929 ▲ +0.22%
crates/cli/src/commands/doctor/config.rs 90.35% 103/114 ▲ +13.08%
crates/common/src/config/errors.rs 96.52% 194/201 ▲ +1.09%
crates/common/src/config/mod.rs 97.13% 7233/7447 ▲ +0.03%
crates/node/src/commands/mod.rs 0.00% 0/59 ● 0.00%
crates/node/src/runtime/mod.rs 47.41% 1162/2451 ● 0.00%
crates/node/src/runtime/reload.rs 96.60% 1561/1616 ▲ +0.02%
History
Commit Total Δ vs base
072622e 82.75% ▲ +0.06%
4280b22 82.74% ▲ +0.06%
cc55c46 (HEAD) 82.77% ▲ +0.08%

thiras and others added 2 commits September 3, 2026 01:43
…g key

Nine of the ten notice sites pass a dotted config label; the retired-env-var
site passes the bare variable name, because that is the thing the operator
set and must unset. The type said "dotted field label" unconditionally,
which misleads exactly the consumers the field exists for — a JSON log
stream or a `doctor` finding filtering on `field` would silently miss the
retired-env-var notice, the one most likely to fire on an inherited
orchestrator variable.

The value is right: `resolve_network_into` already states the convention as
"the label names the source the operator actually wrote". Only the doc was
wrong. The existing test now says so at the assertion.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GqvbhAgEkq1XQ9Dm8TvLsq
…t gate

The reload path emitted resolve-time notices between the phase-1 problem
gate and the phase-2 fallible commits. A `fallible_commit` error returns
before any `infallible_swap`, and `infallible_swap` is where the
notice-bearing sections put their values — so a failing log-level setter
logged a WARN about a security value the node never applied. Emission
moves below the commit loop, where every gate that can abort has passed.

Also from review of #1902:

- `one_section` claimed every caller was a test shim; five were public,
  un-gated wrappers, one of which (`resolve_security`) discarded three
  notices. The four with no production caller are now `#[cfg(test)]`,
  leaving `resolve_discovery` — whose worker records none — as the sole
  production wrapper, and the docstring says so.
- `warn_on_duplicate_origins` still used `tracing::warn!` on the
  pre-`init_tracing` resolve path. It records a notice, and its test now
  asserts the notice rather than leaving emission to code review.
- Doctor findings put `field` in `detail` (fixing a `field: 0: message`
  title stutter) and derive a remediation from its shape: a dotted key is
  edited in the file, a bare env var unset in the environment.
- A `Warn` moves doctor's exit status only under `--strict`; the CHANGELOG
  and two docstrings said otherwise. The CHANGELOG also now records that
  delivery follows the log filter, where raw stderr did not.

Test gaps closed: a phase-2 abort leg (fails on the pre-fix ordering), a
source guard on the startup replay ordering — positional, and invisible to
any test that must install its own subscriber — end-to-end runs through
both `decdn node doctor` and `decdn config validate`, default-value guards
for dht/probe, the `(1..1024)` port edges, and discriminating message
assertions so a swapped per-IP/per-peer body fails. The SIGHUP test now
captures JSON and asserts `field` is a real event field, which is the
property the design claims and rendered text cannot distinguish.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01JcJSKd5VZZjTFP6Hco3gQm
@thiras
thiras merged commit 4de327b into main Sep 2, 2026
25 checks passed
@thiras
thiras deleted the fix/1902-config-notices-log-stream branch September 2, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config-resolve warnings never reach the log stream on the SIGHUP reload path

2 participants