Skip to content

Invalid --tp-address causes proxy to panic instead of failing gracefully #212

@jayvaliya

Description

@jayvaliya

Problem

Passing an invalid --tp-address produces no error at startup. The proxy silently accepts the value and proceeds until it hits an unrelated failure — or in a real setup, panics when the JD client initializes.

Reproduction:

# Commands 1 & 2 — crashes with unrelated "Pool address is missing" panic (dummy token)
cargo run -- --token dummy --tp-address "127.0.0.1"        # missing port
cargo run -- --token dummy --tp-address "127.0.0.1:abc"    # non-numeric port

# Command 3 — hangs on pool connection (no mention of invalid --tp-address)
cargo run -- --token dummy --local --tp-address "localhost"

Output for commands 1 & 2:

User Token: Some("dummy")
...
ERROR dmnd_client::config: Failed to parse pool urls: error decoding response body
thread 'main' panicked at src/lib.rs:144:
Pool address is missing

Output for command 3:

User Token: Some("dummy")
...
INFO  dmnd_client::router: Trying to connect to Pool 127.0.0.1:20000
ERROR dmnd_client::minin_pool_connection: Failed to connect ... retrying in 5s: Connection refused
# Hangs indefinitely — no mention of the invalid --tp-address

In a real setup where pool connection succeeds, the proxy reaches jd_client::start() and panics:

thread 'main' panicked at src/jd_client/mod.rs:110:
The passed value for TP address is not valid. Terminating....
TP_ADDRESS should be in this format `127.0.0.1:8442`

Expected Behavior

The proxy should reject an invalid --tp-address immediately at startup:

Invalid TP address 'localhost'. Expected format: 'host:port' (e.g., '127.0.0.1:8442')
# Proxy exits cleanly

Root Cause

  1. config.rs--tp-address is loaded but never validated, unlike --miner-name which has explicit validation at load time.

  2. jd_client/mod.rs — Three .expect() calls on lines 110–111 and 208–209 panic on bad input. Every other error path in initialize_jd() (15 total) returns None gracefully — these are the only exceptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions