Skip to content

decdn fetch: decouple --provider-address from --node-id so it can guard the --channel-id adopt path #1492

Description

@alpergundogdu

Problem

In crates/common/src/cli/fetch.rs, --provider-address is declared with requires = "node_id":

#[arg(long, value_name = "0xADDR", requires = "node_id")]
pub provider_address: Option<String>,

The decdn fetch --channel-id <id> adopt-by-id path reads --provider-address purely as a guard: it asserts the flag matches the channel's actual on-chain provider and hard-errors on a mismatch (hydrate_channel_by_id), rather than using it to locate the node. The node to dial is derived from the adopted channel's on-chain provider via resolve_node_for_provider.

Because of the requires = "node_id" coupling, a user who wants that provider mismatch-guard is forced to also pass --node-id — which partly defeats the point of adopt-by-id being able to derive the node itself. The combination is awkward, not broken: the guard still works when --node-id is supplied.

Proposal

Relax the coupling so --provider-address can stand alone as a guard on the --channel-id path, while preserving today's behavior on the auto-open path (where --provider-address without --node-id has no discovery step to run and genuinely needs the explicit node).

Options to weigh:

  • Drop requires = "node_id" and instead validate the flag combination in code: --provider-address alone is allowed only alongside --channel-id; on the auto-open path it still requires --node-id.
  • Or keep the clap-level requires and just document the combination in the flag help.

Acceptance criteria

  • decdn fetch --channel-id <id> --provider-address <addr> works without --node-id, using --provider-address as the mismatch guard against the channel's on-chain provider.
  • The auto-open path (--provider-address without --channel-id) keeps its current requirement.
  • cli_command_tree_is_clap_valid still passes; add a unit test for the new allowed/disallowed flag combinations.

Surfaced during review of #1488.

Activity

  1. added this to the v0.1 milestone on Jul 28, 2026
  2. added
    area:cli
    kind:feature
    on Jul 28, 2026
  3. github-actions commented on Jul 28, 2026

    @github-actions

    🎯 Triage report

    The issue identifies an awkward clap arg coupling in crates/common/src/cli/fetch.rs where --provider-address has requires = "node_id", preventing it from being used as a standalone mismatch guard on the --channel-id adopt-by-id path. The proposal is to move the validation into code rather than clap's declarative constraint, allowing --provider-address to stand alone only when paired with --channel-id, while preserving the existing requirement on the auto-open path. Acceptance criteria and the affected code path (hydrate_channel_by_id) are clearly identified.

    📊 Assessment

    Dimension Value Reasoning
    Type Feature Relaxing a CLI constraint to enable a new valid usage pattern; enhances UX rather than fixing broken behavior
    Labels cli, enhancement, medium Scoped to CLI arg parsing, improves ergonomics, not urgent
    Coding agent Suitable Clear scope (single file crates/common/src/cli/fetch.rs), explicit acceptance criteria, and a defined test requirement (cli_command_tree_is_clap_valid + new combo test)

    🔗 Similar issues

    No similar open issues found.

    💡 Notes and suggestions

    Implementation approach:

    1. Remove requires = "node_id" from the --provider-address arg declaration in crates/common/src/cli/fetch.rs.
    2. Add a runtime validation block (likely in the FetchArgs validation or wherever fetch args are resolved) that enforces:
      • If --provider-address is set and --channel-id is not set → require --node-id (current behavior, now enforced in code instead of clap).
      • If --provider-address is set and --channel-id is set → allow without --node-id; the mismatch guard in hydrate_channel_by_id handles the rest.
    3. Unit tests to add:
      • --channel-id <id> --provider-address <addr> → valid (no --node-id needed).
      • --provider-address <addr> alone (no --channel-id, no --node-id) → clap/validation error.
      • --provider-address <addr> --node-id <id> (no --channel-id) → valid (auto-open path, existing behavior).
    4. Confirm cli_command_tree_is_clap_valid still passes after removing the requires constraint.

    Context: Surfaced during review of #1488, suggesting this came up in a real usage flow rather than being hypothetical.

    Generated by Agentic Triage for #1492 · sonnet46 · 22.5 AIC · ⌖ 8.47 AIC · ⊞ 6.2K · ◷

    Add this agentic workflow to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  4. added a commit that references this issue on Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clikind:feature

Fields

Priority

None yet

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions