Skip to content

fix(node): aggregate SIGHUP reload errors across sections (#608) - #615

Merged
yigitdot merged 3 commits into
mainfrom
fix/608-reload-aggregate-errors
May 20, 2026
Merged

yigitdot merged 3 commits into
mainfrom
fix/608-reload-aggregate-errors

Conversation

@yigitdot

@yigitdot yigitdot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Thread a shared ConfigErrorBag through every ReloadableSection::resolve so SIGHUP reload reports every broken field in one error instead of bailing on the first — matches the startup-path aggregation introduced in Add structured config validation pass after resolution that emits all errors at once #222 (closes config: SIGHUP reload should aggregate all resolution problems (like startup #222) #608).
  • Re-export ConfigErrorBag (pub) and promote resolve_payment_into / resolve_observability_into / resolve_security_into to pub so the node crate can share a bag across sections; PinnedHashesSection uses bag.try_with with a PinnedHashes::empty() placeholder so later sections still run.
  • All-or-nothing contract preserved: after every section runs, the bag is collapsed once; any problem → early return with previous values retained for every section.
  • Reload-failure warn line now carries a structured problem_count field for log aggregators; the message no longer hardcodes a section list ("payment, observability, ..."), so it can't drift when a fifth ReloadableSection is added.

Public surface

Minimum needed by the node crate:

  • pub struct ConfigErrorBag + pub fn new / pub fn try_with / pub fn into_result / pub const fn problem_count
  • impl Default for ConfigErrorBag (required by clippy new_without_default since new is pub on a pub type)
  • pub fn resolve_payment_into / resolve_observability_into / resolve_security_into in decdn_common::config

Internal helpers (push, check, check_with, has_field) stay pub(crate).

Test plan

  • cargo nextest run -p decdn-node runtime::reload — new reload_aggregates_problems_across_sections (3 fields across 3 sections) and reload_aggregates_two_problems_in_one_section (2 problems within [payment]) pass; existing 22 reload tests (including all-or-nothing rollback + fallible-commit-fails coverage) still pass.
  • cargo nextest run -p decdn-common config — 253 config tests pass.
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt -- --check
  • Full pre-commit suite (cargo-doc with -D warnings, cargo-deny)

🤖 Generated with Claude Code

Thread a single `ConfigErrorBag` through every reloadable section's
resolve so an operator who breaks N fields sees them all in one error,
matching the startup-path aggregation from #222 instead of fixing them
one SIGHUP at a time. `ConfigErrorBag` and the `*_into` worker variants
are re-exported from `decdn_common::config` for the node crate to use.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the configuration reload logic to aggregate errors across all sections using a shared ConfigErrorBag. Previously, the reload process would terminate at the first encountered error; now, it collects all validation issues and reports them together, matching the behavior of the startup configuration pass. To support this, the ReloadableSection trait and several internal resolution functions were updated to be public and accept the error bag. Additionally, new tests were added to ensure that multiple errors are correctly captured and reported during a reload. I have no feedback to provide as there were no review comments.

@github-actions

github-actions Bot commented May 20, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 89.94% (was 89.89%, ▲ +0.04%) — 16676/18542 lines

File Coverage Lines Δ
crates/common/src/config/errors.rs 95.42% 146/153 ▼ 1.85%
crates/common/src/config/mod.rs 96.36% 4233/4393 ● 0.00%
crates/node/src/runtime/reload.rs 95.98% 1383/1441 ▲ +0.26%
History
Commit Total Δ vs base
e3df925 89.92% ▲ +0.03%
88ebb8d 89.94% ▲ +0.03%
3e46398 (HEAD) 89.94% ▲ +0.04%

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.

Pull request overview

Improves the node’s SIGHUP hot-reload experience by aggregating config resolution errors across all reloadable sections into a single ConfigErrorBag, matching the startup-path behavior introduced in #222, while preserving the existing all-or-nothing reload semantics.

Changes:

  • Thread a single ConfigErrorBag through all ReloadableSection::resolve calls during SIGHUP reload, collapsing it once after all sections run.
  • Re-export ConfigErrorBag from decdn_common::config and make resolve_payment_into, resolve_observability_into, and resolve_security_into public for cross-section bag sharing.
  • Add targeted unit tests ensuring (a) aggregation across multiple sections and (b) multiple errors within a single section are both surfaced in one reload error.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/node/src/runtime/reload.rs Uses a shared ConfigErrorBag across all reloadable sections during SIGHUP reload and adds tests for cross-section and within-section error aggregation.
crates/common/src/config/mod.rs Re-exports ConfigErrorBag and exposes *_into resolver helpers so reload can share a single bag across sections.
crates/common/src/config/errors.rs Makes ConfigErrorBag public (and its API public) so it can be used from the node crate during reload aggregation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

yigitdot and others added 2 commits May 20, 2026 15:04
Address findings from /pr-review-toolkit:review-pr on this branch:

- Demote ConfigErrorBag::{push, check, check_with, has_field} back to
  pub(crate); only new/try_with/into_result/problem_count need to be
  reachable from the node crate. Restores the IDENTITY_REGION /
  IDENTITY_DATA_DIR intra-doc-link on has_field now that it's no longer
  pub. The struct's own doc references to `check`/`push` are also
  downgraded from intra-doc-links to plain backticks for the same
  rustdoc::private_intra_doc_links reason.
- Add ConfigErrorBag::problem_count so the reload-failure warn line
  can carry a structured problem_count field for log aggregators
  (previously only the bullet list in %err was filterable).
- Drop the hardcoded "payment, observability, cache.pinned_hashes, and
  security" section list from the warn message — it would silently
  drift when a fifth ReloadableSection is registered. The %err bullet
  list still names each offending field; the warn line now just
  asserts "all reloadable sections retained at their previous values".
- Reword the module-doc Phase-1 description so the sentinel-buffer
  rule matches the broader trait contract ("every section populates
  its buffer on every resolve"), not just sections that pushed
  problems.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Trim over-explained comments added in the earlier commits on this
branch:

- `ConfigErrorBag::problem_count` doc: drop the `.matches(...).count()`
  forensic detail; keep the WHY ("read before `into_result` when the
  count is needed alongside the consumed error").
- `runtime::reload` module-doc Phase 1: collapse from 13 lines to 10
  while keeping the dyn-safety rationale and sentinel/clear_buffer
  invariant, plus the operator-UX framing.
- `reload()` body comment: drop the redundant operator-UX narrative
  that the module doc already carries.
- `PinnedHashesSection::resolve` inline: tighten while keeping the
  load-bearing safety claim ("`reload()`'s early return guarantees
  the placeholder never reaches swap").
- Two new test docstrings: drop the per-test "what's in the config
  file" narrative that the test body shows; keep the WHY (all-or-
  nothing contract, short-circuit guard).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@yigitdot
yigitdot requested a review from alpergundogdu May 20, 2026 15:53
@yigitdot
yigitdot merged commit 1971758 into main May 20, 2026
11 checks passed
@yigitdot
yigitdot deleted the fix/608-reload-aggregate-errors branch May 20, 2026 16:57
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: SIGHUP reload should aggregate all resolution problems (like startup #222)

2 participants