diem/diem · error

Invalid faucet URL specified

Error message

Invalid faucet URL specified

What it means

ClientProxy::new parses the explicitly provided faucet_url via Url::parse and unwraps with expect('Invalid faucet URL specified'). Since Url::parse errors don't fit CliError nicely here, a malformed faucet URL aborts construction with this panic — the supplied URL is not a valid absolute URL.

Source

Thrown at crates/diem/src/client_proxy.rs:134

        };

        let dd_account = if testnet_designated_dealer_account_file.is_empty() {
            None
        } else {
            let dd_account_key = generate_key::load_key(testnet_designated_dealer_account_file);
            let dd_account_data = Self::get_account_data_from_address(
                &client,
                testnet_dd_account_address(),
                true,
                Some(KeyPair::from(dd_account_key)),
                None,
            )
            .await?;
            Some(dd_account_data)
        };

        let faucet_url = if let Some(faucet_url) = &faucet_url {
            Url::parse(faucet_url).expect("Invalid faucet URL specified")
        } else {
            url.join("/mint")
                .expect("Failed to construct faucet URL from JSON-RPC URL")
        };

        Ok(ClientProxy {
            chain_id,
            client,
            faucet_url,
            diem_root_account,
            tc_account,
            testnet_designated_dealer_account: dd_account,
            quiet_wait,
            url,
        })
    }

    /// Get account using specific address.

View on GitHub (pinned to fc4714a8ea)

Solutions

  1. Fix the faucet_url to a fully qualified URL including scheme, e.g. http://localhost:8000 or https://faucet.example.test
  2. Trim whitespace and stray characters from the configured value
  3. Omit faucet_url entirely so the proxy derives it from the JSON-RPC URL (url.join("/mint"))
  4. Validate the URL with a quick parse (curl or url parser) before wiring it into config
  5. Check documentation for the expected faucet endpoint format of your network

Example fix

// before
// faucet_url = "localhost:8080"          // no scheme -> panic
// after
// faucet_url = "http://localhost:8080"  // valid absolute URL
Defensive patterns

Strategy: validation

Validate before calling

import { URL } from 'url';
export function isValidFaucetUrl(u: string): boolean {
  try { const p = new URL(u); return p.protocol === 'http:' || p.protocol === 'https:'; } catch { return false; }
}

Type guard

function isHttpUrl(value: unknown): value is string {
  if (typeof value !== 'string') return false;
  try { const u = new URL(value); return u.protocol === 'http:' || u.protocol === 'https:'; } catch { return false; }
}

Prevention

When it happens

Trigger: Caller passes a faucet_url string that fails Url::parse (missing scheme like 'localhost:8080' without http://, illegal characters, typos) when constructing ClientProxy.

Common situations: Config file or CLI flag supplies faucet URL without the http(s):// scheme; trailing garbage or spaces in the configured URL; using 'localhost:8000' style shorthand; environment-specific override pointing at a bad value.

Related errors


AI-assisted analysis of diem/diem@fc4714a8ea (2026-09-04). Data as JSON: /api/errors/d279dabbc3d820cf. Report an issue: GitHub.