Skip to content

feat(libp2p): validate config options at startup - #3659

Open
sharmis-tp wants to merge 1 commit into
libp2p:mainfrom
sharmis-tp:feat/config-validation
Open

sharmis-tp wants to merge 1 commit into
libp2p:mainfrom
sharmis-tp:feat/config-validation

Conversation

@sharmis-tp

Copy link
Copy Markdown

Description

Related #1573

Adds config validation to the libp2p package only, as suggested on the issue; other modules can follow. validateConfig() now checks the options this package consumes directly with a valibot schema and fails fast with an InvalidParametersError that names the field, e.g. "Invalid libp2p config: addresses.listen.1 is not a valid multiaddr: foo".

Validated: address lists (listen, announce, noAnnounce, appendAnnounce, connectionManager.allow/deny) must parse as multiaddrs; connection manager limits and timeouts must be non-negative numbers (Infinity allowed); maxConnections must be > 0; connectionMonitor flags must be booleans; transportManager.faultTolerance must be a FaultTolerance value. Unknown keys are allowed so services keep their own options.

Notes & open questions

  • Library choice and bundle sizes are in the issue comment: valibot adds about 1.5 KB gzip to the browser bundle.
  • Multiaddr instances are accepted in address lists because the address manager already calls toString() on them.
  • The existing "maxConnections must be greater than 0" wording is kept, so the connection manager test still passes.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@sharmis-tp
sharmis-tp requested a review from a team as a code owner October 10, 2026 16:48

This branch has not been deployed

No deployments
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.

1 participant