quickwit-oss/quickwit · info

1 is always non-zero.

Error message

1 is always non-zero.

What it means

This is a panic raised from an `.expect()` on `NonZeroU32::new(1u32)` while limiting the Azure blob listing to one result. The literal 1 is by definition non-zero, so `NonZeroU32::new` can never return `None`; the message documents an unreachable invariant rather than a recoverable failure. It exists purely to satisfy the Option-returning constructor of the `NonZeroU32` type.

Source

Thrown at quickwit/quickwit-storage/src/object_storage/azure_blob_storage.rs:347

        // Commit all uploaded blocks.
        blob_client
            .put_block_list(block_list)
            .into_future()
            .await
            .map_err(AzureErrorWrapper::from)?;

        Ok(())
    }
}

#[async_trait]
impl Storage for AzureBlobStorage {
    async fn check_connectivity(&self) -> anyhow::Result<()> {
        if let Some(first_blob_result) = self
            .container_client
            .list_blobs()
            .max_results(NonZeroU32::new(1u32).expect("1 is always non-zero."))
            .into_stream()
            .next()
            .await
        {
            let _ = first_blob_result?;
        }
        Ok(())
    }

    #[instrument(name = "storage.azure.put", level = "debug", skip(self, payload), fields(payload_len = payload.len()))]
    async fn put(
        &self,
        path: &Path,
        payload: Box<dyn crate::PutPayload>,
    ) -> crate::StorageResult<()> {
        crate::metrics::OBJECT_STORAGE_PUT_TOTAL.inc();
        let name = self.blob_name(path);
        let total_len = payload.len();

View on GitHub (pinned to a39730c5cd)

Solutions

  1. No action needed: this panic is unreachable with the literal value 1.
  2. If the limit becomes dynamic, validate it is non-zero before calling `NonZeroU32::new` (e.g. `NonZeroU32::new(limit).ok_or_else(|| anyhow!("max_results must be > 0"))?`).

Example fix

// before (only if limit becomes dynamic)
.max_results(NonZeroU32::new(limit).expect("1 is always non-zero."))
// after
.max_results(NonZeroU32::new(limit)
    .ok_or_else(|| anyhow::anyhow!("max_results must be greater than zero"))?)
Defensive patterns

Strategy: validation

Validate before calling

// Only relevant if the max_results value becomes dynamic
if limit == 0 { return Err(anyhow::anyhow!("max_results must be greater than zero")); }
let max_results = NonZeroU32::new(limit).unwrap();

Prevention

When it happens

Trigger: None at runtime. The panic fires only if `NonZeroU32::new(1u32)` returns `None`, which is impossible since 1 != 0. It can only ever be hit if the constant is refactored to a dynamic value that could be zero.

Common situations: Developers never hit this in production. It may surface only during refactoring when someone replaces the hardcoded `1u32` with a user-supplied or computed limit (e.g. a configured page size of 0) without validating it first.

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 quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/4797b79bea13cd93. Report an issue: GitHub.