astrid-runtime/astrid · error

FastCDC candidate has non-FastCDC parameters

Error message

FastCDC candidate has non-FastCDC parameters

What it means

In the chunker-evidence crate, `fastcdc_target_bytes()` extracts the target size from a candidate's parameters and only accepts `Parameters::FastCdc2020`. Any other parameter variant reaching this code path is an internal invariant violation: a FastCDC candidate was constructed with non-FastCDC parameters.

Solutions

  1. Check how the candidate was built and ensure `Parameters::FastCdc2020` is used for FastCDC candidates.
  2. Filter candidates by algorithm before calling FastCDC-specific visitors.
  3. If a new Parameters variant was added, extend this matcher to handle it explicitly.
Defensive patterns

Strategy: type-guard

Validate before calling

// Only pass FastCDC candidates to FastCDC-specific visitors
candidates.iter().filter(|c| matches!(c.parameters, Parameters::FastCdc2020 { .. }))

Type guard

fn is_fastcdc(p: &Parameters) -> bool {
    matches!(p, Parameters::FastCdc2020 { .. })
}

Try / catch

match fastcdc_target_bytes(&candidate) {
    Ok(target) => use_target(target),
    Err(e) => log::error!("non-FastCDC params reached FastCDC path: {e}"), // fix construction site
}

Prevention

When it happens

Trigger: Calling `fastcdc_target_bytes()` (via `visit_records`/`visit_boundary_chunks`) on a candidate whose `parameters` enum is not `Parameters::FastCdc2020`.

Common situations: A bug in candidate construction mixing parameter kinds; future parameter variants added without updating this matcher; code that assumes all candidates are FastCDC when the candidates list can contain other algorithms.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/b03a6f7db1e44021. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-storage-chunker-evidence/src/algorithm.rs:141

                    visit(chunk)
                })?;
            },
            Algorithm::MothCaterpillar => {
                let mut chunker = MothReadChunker::try_new(reader, minimum, maximum)?;
                while let Some(segment) = chunker.next()? {
                    for _ in 0..segment.chunk_count() {
                        visit(segment.dedup_key())?;
                    }
                }
            },
        }
        Ok(())
    }

    fn fastcdc_target_bytes(&self) -> Result<u32> {
        match self.parameters {
            Parameters::FastCdc2020 { target_bytes, .. } => Ok(target_bytes),
            _ => bail!("FastCDC candidate has non-FastCDC parameters"),
        }
    }
}

pub fn candidates(target_kib: u32) -> Result<Vec<Candidate>> {
    if !(8..=256).contains(&target_kib) || !target_kib.is_power_of_two() {
        bail!("target KiB must be a power of two in 8..=256");
    }
    let target = target_kib
        .checked_mul(1024)
        .ok_or_else(|| anyhow::anyhow!("target byte size overflow"))?;

    let fast_minimum = target / 4;
    let fast_maximum = target
        .checked_mul(4)
        .ok_or_else(|| anyhow::anyhow!("FastCDC maximum overflow"))?;
    let narrow_minimum = checked_ratio(target, 3, 4, "narrow MinCDC minimum")?;
    let narrow_maximum = checked_ratio(target, 5, 4, "narrow MinCDC maximum")?;

View on GitHub (pinned to affd8760f4)