#36580 refactor: Use util::log::FormatString in BaseIndex::FatalErrorf and LogConnectFailure

ReviewabilityReviewsAgreementSize
#36580 maflcko refactor: Use util::log::FormatString in BaseIndex::FatalErrorf and LogConnectFailureReady1Positive6
  • Prevent trailing newlines in logging helpers from producing escaped newline characters in log output
  • Catch invalid format strings at compile time rather than letting malformed logs slip into runtime
  • Ready to review
  • Approval without stated reasons (stickies-v)
  • No open objections or unresolved concerns
  • 6 lines added or modified outside tests
  • 0 lines added or modified in tests
  • 7 lines removed in total
  • 3 files, 1 commits
Indexes#11 of 11
P4 · cleanup
  • P4 because compile-time checks on index fatal error formatting are a minor internal cleanup
  • Has no impact on index correctness or performance
P2P#70 of 71
P4 · cleanup
  • P4 because formatting guards for connection failures do not alter networking logic or reliability
  • Offers minor hygiene benefits with no behavioral change
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Replaces util::ConstevalFormatString with util::log::FormatString in BaseIndex::FatalErrorf and LogConnectFailure. This enables compile-time verification that format strings passed to these logging helper functions do not contain redundant trailing newlines.

Problem: Functions that format strings for logging without using util::log::FormatString can accept trailing newlines, which causes logging sanitization to output escaped \x0a characters.

Evidence of importance:

  • PR description: "Both functions format a message that is ultimately logged, so it must not contain a redundant trailing newline. Otherwise, it could lead to escaped \x0a inside log messages. This continues https://github.com/bitcoin/bitcoin/pull/36397"

Risk of a mistake: low (other). A mistake in format string types would fail at compile time and carries no runtime or consensus risk.

Changed since the previous assessment: Now includes the complete patch for the single commit; the approach and touched call sites are unchanged.

Reviewability

Ready

Nothing known that would invalidate a review now.

Waiting on (from the thread read):

  • nothing

Agreement

Positive

support without stated reasons, no open objection (stickies-v)

Thread notes: Initial record. stickies-v provided an ACK without comments. / Initial record. stickies-v gave an ACK with no rationale.

Objections, suggestions, and questions: none recorded.

Support:

  • stickies-v (member) (ACK, 2026-10-21): (no reason given) [not substantive]

Participants:

  • stickies-v (member, support, 1 statements 2026-10-21 to 2026-10-21): ACKed commit hash

Files

0 lines under test/bench/ci.

  • src/index/base.h +3/-3
  • src/netbase.cpp +2/-2
  • src/index/base.cpp +1/-2

Card

The short text the ranking pass compares across PRs.

Switches format string parameters in BaseIndex::FatalErrorf and LogConnectFailure from util::ConstevalFormatString to util::log::FormatString. This enforces compile-time checks preventing redundant trailing newlines that would otherwise be rendered as escaped \x0a sequences in log files. The author notes this continues cleanup from PR 36397.

Data

dossier JSON · extract JSON · model ledger, generated 2026-10-22T01:17, confidence high, input hash 99e40f5d3ed1d8cd
thread read through 2026-10-21 (1 statements), head fafbcadc1b
labels: Refactoring

Categories

Indexes

P4 · cleanup

Adopts `util::log::FormatString` to enforce compile-time checks against trailing newlines in index fatal error logging. This is a minor internal code cleanup with no impact on index correctness or performance.

Membership: Modifies `BaseIndex::FatalErrorf` in `src/index/base.h` and `src/index/base.cpp`.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 0

P2P

P4 · cleanup

Switches `LogConnectFailure` to use `util::log::FormatString` to disallow redundant trailing newlines. This is an internal formatting guard that does not affect P2P networking logic or connection reliability.

Membership: Modifies `LogConnectFailure` in `src/netbase.cpp`, part of the connection handling infrastructure.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 0