zeroclaw-labs/zeroclaw · error

address '{address}' sets bits beyond /{len}

Error message

address '{address}' sets bits beyond /{len}

What it means

Error "address '{address}' sets bits beyond /{len}" thrown in zeroclaw-labs/zeroclaw.

Source

Thrown at crates/zeroclaw-infra/src/net_guard.rs:636

            .ok_or_else(|| anyhow::Error::msg("missing '/<prefix-length>'"))?;

        let network = address
            .parse::<std::net::Ipv6Addr>()
            .map_err(|e| anyhow::Error::msg(format!("'{address}' is not an IPv6 address: {e}")))?;
        let len = length
            .parse::<u8>()
            .map_err(|e| anyhow::Error::msg(format!("'{length}' is not a prefix length: {e}")))?;

        if !RFC6052_PREFIX_LENGTHS.contains(&len) {
            anyhow::bail!(
                "prefix length /{len} is not one of the RFC 6052 lengths /32, /40, /48, /56, /64, /96"
            );
        }

        // `len` is at most 96 here, so the shift is always in range.
        let host_bits = u128::MAX >> len;
        if u128::from_be_bytes(network.octets()) & host_bits != 0 {
            anyhow::bail!("address '{address}' sets bits beyond /{len}");
        }

        Ok(Self { network, len })
    }

    /// The prefix length in bits.
    #[must_use]
    pub const fn prefix_len(&self) -> u8 {
        self.len
    }

    /// The prefix network address, with all bits beyond [`Self::prefix_len`]
    /// zero.
    #[must_use]
    pub const fn network(&self) -> std::net::Ipv6Addr {
        self.network
    }

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Clear the bits beyond the prefix length in the NAT64 address so it is a proper network prefix.

When it happens

Trigger: Thrown at crates/zeroclaw-infra/src/net_guard.rs:636 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/748f7fd7b9525816. Report an issue: GitHub.