libnyanpasu/clash-nyanpasu · error

REJECT is missing in /proxies

Error message

REJECT is missing in /proxies

What it means

Thrown by `Proxies::from_responses` when the `/proxies` response from the Clash/Mihomo core lacks the built-in `REJECT` proxy entry. Like `DIRECT`, `REJECT` is assumed to always exist in a well-formed /proxies payload; its absence indicates the response is not a valid proxies map and the constructor fails fast rather than building an incomplete model.

Source

Thrown at backend/tauri/src/core/clash/proxies.rs:127

                    )
                })
                .collect()
        };

        // 2. Map every provider-owned proxy by name. Mihomo 1.19.28 no longer
        // includes these nodes in /proxies, so their metadata must come from
        // /providers/proxies.
        let provider_map = provider_proxy_map(&providers_proxies);
        let generate_item = |name: &str| resolve_proxy(name, &inner_proxies, &provider_map);

        let global = inner_proxies.get("GLOBAL");
        let direct = inner_proxies
            .get("DIRECT")
            .ok_or(anyhow::anyhow!("DIRECT is missing in /proxies"))?
            .clone(); // It should be always exists
        let reject = inner_proxies
            .get("REJECT")
            .ok_or(anyhow::anyhow!("REJECT is missing in /proxies"))?
            .clone(); // It should be always exists

        // 3. generate the proxies groups
        let groups: Vec<ProxyGroupItem> = match global {
            Some(api::ProxyItem { all: Some(all), .. }) => {
                let all = all.clone();
                all.into_iter()
                    .filter(|name| {
                        matches!(
                            inner_proxies.get(name),
                            Some(api::ProxyItem { all: Some(_), .. })
                        )
                    })
                    .map(|name| {
                        let item = inner_proxies
                            .get(&name)
                            .unwrap_or(&api::ProxyItem::default())
                            .clone();

View on GitHub (pinned to f7dbce2997)

Solutions

  1. Confirm the core is fully started and re-fetch /proxies; missing REJECT is usually a not-ready or malformed response.
  2. Curl the external controller's /proxies endpoint and check that "REJECT" is present in the JSON.
  3. Verify the external controller address, port and secret are correct so you are not parsing an error body.
  4. Update or replace non-standard cores that omit built-in proxy entries.

Example fix

// before
let proxies = Proxies::from_responses(proxies_res, providers_res)?;
// after
for builtin in ["DIRECT", "REJECT"] {
    if !proxies_res.proxies.contains_key(builtin) {
        anyhow::bail!("core /proxies missing built-in {builtin}; response not ready");
    }
}
let proxies = Proxies::from_responses(proxies_res, providers_res)?;
Defensive patterns

Strategy: validation

Validate before calling

if !proxies_res.proxies.contains_key("REJECT") {
    anyhow::bail!("core /proxies not ready: missing REJECT");
}

Type guard

fn has_builtin_proxies(res: &api::ProxiesRes) -> bool {
    res.proxies.contains_key("DIRECT") && res.proxies.contains_key("REJECT")
}

Try / catch

match Proxies::from_responses(proxies_res, providers_res) {
    Ok(p) => p,
    Err(e) if e.to_string().contains("REJECT is missing") => {
        anyhow::bail!("core response malformed or not ready, retry: {e}")
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `Proxies::from_responses` where the inner proxies map from `GET /proxies` has no `"REJECT"` key — same causes as the missing-DIRECT case: empty/error response, wrong endpoint or port, non-standard core, partial startup.

Common situations: Hitting the controller before the core finished initializing; external controller misconfigured (wrong secret/port returning an error body that deserializes into an empty map); custom core builds or middleware stripping built-in entries; API version drift.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08). Data as JSON: /api/errors/26f2f3002701e0df. Report an issue: GitHub.