Skip to content

common: [network.discovery] is skipped by ${VAR} env expansion, unlike its sibling relay_urls — dns_origin passes through as a literal string #863

Closed

Description

@thiras

Severity: MEDIUM — from the 2026-06-10 full-repository review (#829/#818 surface).

Location

crates/common/src/config/mod.rs:2432-2439 — the expand_env network block expands relay_url + relay_urls only; there is no leg for discovery.pkarr_url, discovery.dns_origin, or discovery.peers.*.{relay_url,addrs}.

Scenario

An operator reusing the documented single-TOML-template-across-deployments pattern (expand_env doc, mod.rs:2411-2414) writes:

  • pkarr_url = "${PKARR_URL}" → fails URL parse with a confusing invalid URL "${PKARR_URL}"
  • dns_origin = "${DNS_ORIGIN}" → worse: it passes resolution (only checked non-empty, mod.rs:605-612) and reaches node bring-up as the literal string, silently breaking peer resolution
  • peer addrs = ["${NODE1_ADDR}"] → fails late with a misleading parse error

Not a duplicate

#842 is deny_unknown_fields; #843 is the relay env override; neither touches env expansion of the new discovery knobs.

Fix direction

Add a discovery block to expand_env mirroring the relay_urls loop (pkarr_url, dns_origin, per-peer relay_url + addrs), with indexed ctx labels.

Activity

  1. added
    kind:bug
    prio:medium
    rust
    on Jun 10, 2026
  2. github-actions commented on Jun 10, 2026

    @github-actions

    🎯 Triage report

    expand_env in crates/common/src/config/mod.rs handles the [network] block at lines 2432-2439 but stops after relay_url/relay_urls — the entire [network.discovery] sub-block (pkarr_url, dns_origin, per-peer relay_url and addrs) is never processed. The silent failure for dns_origin is the most dangerous case: it passes the non-empty check at resolution and propagates to node bring-up as the literal string ${DNS_ORIGIN}, silently breaking peer discovery with no diagnostic. The other fields (pkarr_url, peer addrs) at least fail fast with confusing parse errors.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Missing env-expansion leg causes silent misconfiguration (dns_origin) or misleading parse failures
    Labels technical added; bug, medium, rust already applied Consistent with sibling #843; all three priority/language/type labels were already set
    Coding agent Suitable Exact code location known (mod.rs:2432-2439), fix mirrors existing relay_urls loop pattern, all fields and their types are identified

    🔗 Similar issues

    💡 Notes and suggestions

    Verified in code: expand_env network block (lines 2432-2439) handles only relay_url and relay_urls. The DiscoveryConfig struct has three fields needing expansion:

    DiscoveryConfig.pkarr_url       → Option<String>   (URL parse — fails on unexpanded ${VAR})
    DiscoveryConfig.dns_origin      → Option<String>   (non-empty check only — silently passes literal!)
    DiscoveryConfig.peers           → HashMap<String, DiscoveryPeer>
      DiscoveryPeer.relay_url       → Option<String>   (URL parse)
      DiscoveryPeer.addrs           → Vec<String>      (SocketAddr parse)
    

    Fix checklist:

    • After the relay_urls loop, add a if let Some(d) = n.discovery.as_mut() block
    • Expand d.pkarr_url with ctx "network.discovery.pkarr_url"
    • Expand d.dns_origin with ctx "network.discovery.dns_origin"
    • Iterate d.peers (if Some): for each (node_id, peer), expand peer.relay_url with ctx "network.discovery.peers[{node_id}].relay_url" and each entry in peer.addrs with ctx "network.discovery.peers[{node_id}].addrs[{idx}]"
    • Add a regression test in the existing expand_env test block mirroring the relay_urls env-expansion test (set PKARR_URL, DNS_ORIGIN, NODE1_ADDR env vars, call expand_env, assert substitution)

    Note on dns_origin: The silent passthrough makes this the higher-priority fix path. Even though pkarr_url gives a confusing error, dns_origin gives no error — the node starts with dns_origin = "${DNS_ORIGIN}" and all peer lookups quietly fail.

    Generated by Agentic Triage for issue #863 · sonnet46 743.8K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. self-assigned this
    on Jun 10, 2026
  4. added 2 commits that reference this issue on Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugprio:mediumrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions