AprilNEA/OpenLogi · error

captured profile has too many identities to sanitize

Error message

captured profile has too many identities to sanitize

What it means

Raised by `ordinal` in `record_profile/sanitize.rs` when converting a device's index (index+1) into a `SyntheticIdentityOrdinal` fails — either the value overflows `u16` or the candidate ordinal is rejected by `SyntheticIdentityOrdinal::new` (e.g. zero is invalid). It means the captured inventory contains more paired devices than the synthetic-identity scheme can name (65,535), or an index arithmetic bug produced zero.

Solutions

  1. Inspect the snapshot's `paired` length — if it is absurd, the agent snapshot is corrupt; restart the agent.
  2. Verify the sanitizer iterates indices from 0 without a pre-increment bug that could push the ordinal out of range.
  3. If a legit large inventory is intended, the synthetic-identity ordinal width in `openlogi-fixture` would need widening — propose that upstream rather than bypassing the guard.
Defensive patterns

Strategy: validation

Validate before calling

if inventory.paired.len() > u16::MAX as usize { eprintln!("inventory too large to sanitize"); }

Prevention

When it happens

Trigger: Calling `inventory` or `standalone` sanitization on a `DeviceInventory`/`StandaloneDevice` whose `paired`/device list length exceeds `u16::MAX - 1` entries, or an index wrap (via `saturating_add` on `usize::MAX`) yields 0 which `SyntheticIdentityOrdinal::new` rejects.

Common situations: Effectively only reachable with a corrupted or hostile agent snapshot reporting an absurd number of paired devices, or a sanitizer indexing bug; real receivers hold far fewer devices, so this is a defensive overflow guard.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of AprilNEA/OpenLogi@e846e6f4b4 (2026-09-13). Data as JSON: /api/errors/bc7a4e1e75516ed7. Report an issue: GitHub.

Appendix: source

Thrown at crates/openlogi-cli/src/cmd/fixture/record_profile/sanitize.rs:55

pub(super) fn standalone(device: &mut StandaloneDevice) -> Result<()> {
    let ordinal = ordinal(0)?;
    device.address.identity =
        profile_identity(SyntheticIdentityKind::RawHidProfileIdentity, ordinal)?;
    if device.serial_number.is_some() {
        device.serial_number = Some(profile_identity(
            SyntheticIdentityKind::DeviceSerialNumber,
            ordinal,
        )?);
    }
    if device.unit_id != [0; 4] {
        device.unit_id = unit_id(ordinal)?;
    }
    Ok(())
}

fn ordinal(index: usize) -> Result<SyntheticIdentityOrdinal> {
    let value = u16::try_from(index.saturating_add(1))
        .map_err(|_| anyhow!("captured profile has too many identities to sanitize"))?;
    SyntheticIdentityOrdinal::new(value)
        .map_err(|_| anyhow!("captured profile has too many identities to sanitize"))
}

fn profile_identity(
    kind: SyntheticIdentityKind,
    ordinal: SyntheticIdentityOrdinal,
) -> Result<String> {
    generate_synthetic_identity(kind, ordinal)
        .as_profile_str()
        .map(str::to_string)
        .ok_or_else(|| anyhow!("fixture identity policy returned the wrong representation"))
}

fn unit_id(ordinal: SyntheticIdentityOrdinal) -> Result<[u8; 4]> {
    match generate_synthetic_identity(SyntheticIdentityKind::DeviceUnitId, ordinal) {
        SyntheticIdentityValue::DeviceUnitId(value) => Ok(value),
        _ => Err(anyhow!(

View on GitHub (pinned to e846e6f4b4)