{"record":{"id":"e5f1e4337bc8df46","repo":"zeroclaw-labs/zeroclaw","slug":"unsupported-input-sample-format-format","errorCode":null,"errorMessage":"Unsupported input sample format: {format}","messagePattern":"Unsupported input sample format: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-channels/src/voice_wake.rs","lineNumber":57,"sourceCode":"\nimpl TryFrom<cpal::SampleFormat> for PcmSampleFormat {\n    type Error = anyhow::Error;\n\n    fn try_from(format: cpal::SampleFormat) -> Result<Self> {\n        match format {\n            cpal::SampleFormat::F32 => Ok(Self::F32),\n            cpal::SampleFormat::F64 => Ok(Self::F64),\n            cpal::SampleFormat::I8 => Ok(Self::I8),\n            cpal::SampleFormat::I16 => Ok(Self::I16),\n            cpal::SampleFormat::I24 => Ok(Self::I24),\n            cpal::SampleFormat::I32 => Ok(Self::I32),\n            cpal::SampleFormat::I64 => Ok(Self::I64),\n            cpal::SampleFormat::U8 => Ok(Self::U8),\n            cpal::SampleFormat::U16 => Ok(Self::U16),\n            cpal::SampleFormat::U24 => Ok(Self::U24),\n            cpal::SampleFormat::U32 => Ok(Self::U32),\n            cpal::SampleFormat::U64 => Ok(Self::U64),\n            format => bail!(\"Unsupported input sample format: {format}\"),\n        }\n    }\n}\n\nfn build_input_stream<T>(\n    device: &cpal::Device,\n    config: cpal::StreamConfig,\n    audio_tx: mpsc::Sender<Vec<f32>>,\n) -> Result<cpal::Stream, cpal::Error>\nwhere\n    T: cpal::SizedSample,\n    f32: cpal::FromSample<T>,\n{\n    use cpal::traits::DeviceTrait;\n\n    device.build_input_stream(\n        config,\n        move |data: &[T], _: &cpal::InputCallbackInfo| {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-channels/src/voice_wake.rs#L39-L75","documentation":"Raised by PcmSampleFormat::try_from in the voice_wake channel when the cpal SampleFormat reported by the default input device's default_input_config() matches none of the twelve variants the channel maps (F32/F64/I8-I64/U8-U64 including 24-bit). Because the match covers every variant of the cpal version this crate was built against, the wildcard arm only fires when the compiled cpal exposes a format variant this code was never taught — i.e. a cpal/zeroclaw-channels version mismatch.","triggerScenarios":"VoiceWakeChannel::listen -> device.default_input_config() returns a SampleFormat added by a newer cpal than the one zeroclaw-channels' enum mapping supports (cargo resolved a newer cpal semver-compatible copy, or a custom build mixed versions); exotic host/device back-ends reporting a rare format land on the wildcard arm. The error surfaces at channel startup, before any audio flows.","commonSituations":"A `cargo update` bumps cpal to a release that introduces a new SampleFormat variant while zeroclaw-channels is pinned older; building with a fork/patched cpal; a new ALSA/CoreAudio device exposing a format the current mapping predates.","solutions":["Align versions: pin cpal to the exact version zeroclaw-channels was built against (cargo update -p cpal --precise <ver>) or update zeroclaw-channels to a release that maps the new format.","Run cargo tree -i cpal to find who pulled the mismatched cpal copy.","As a workaround, point the OS default input device at a plain 16-bit/float PCM device so default_input_config() reports a mapped format.","If it reproduces with aligned versions, report the device and its reported format so the mapping gains the variant."],"exampleFix":"# before — Cargo.lock drifted, newer cpal adds a SampleFormat variant\n# cargo tree -i cpal  -> cpal v0.16.x (mapping written for 0.15)\n\n# after — pin back to the compatible release\ncargo update -p cpal --precise 0.15.3","handlingStrategy":"validation","validationCode":"// Probe the default input device's format before starting the channel.\nuse cpal::traits::{DeviceTrait, HostTrait};\nlet device = cpal::default_host().default_input_device()\n    .ok_or_else(|| anyhow::anyhow!(\"no default input device\"))?;\nlet fmt = device.default_input_config()?.sample_format();\nlet supported = matches!(fmt, cpal::SampleFormat::F32 | cpal::SampleFormat::F64\n    | cpal::SampleFormat::I8 | cpal::SampleFormat::I16 | cpal::SampleFormat::I24\n    | cpal::SampleFormat::I32 | cpal::SampleFormat::I64 | cpal::SampleFormat::U8\n    | cpal::SampleFormat::U16 | cpal::SampleFormat::U24 | cpal::SampleFormat::U32\n    | cpal::SampleFormat::U64);\nanyhow::ensure!(supported, \"device reports unmapped sample format {fmt}; align cpal/zeroclaw-channels versions\");","typeGuard":null,"tryCatchPattern":"match voice_wake.listen(tx).await {\n    Ok(()) => unreachable!(),\n    Err(e) if e.to_string().contains(\"Unsupported input sample format\") => {\n        // Version skew, not runtime state: fail loudly with the reported format;\n        // do not retry — pin versions or update the channel mapping first.\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Lock cpal in Cargo.lock (or use a lockfile-aware CI) so cargo update cannot silently introduce format variants.","On startup, probe default_input_config() and fail fast with a clear message instead of mid-listen surprises.","Check cargo tree -i cpal after any dependency bump in a build that also uses audio crates.","Prefer devices/configs pinned to 16-bit or float PCM, which every mapping version supports."],"tags":["voice-wake","cpal","audio","sample-format","version-mismatch"],"backgroundTag":"unsupported-audio-sample-format","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}