{"record":{"id":"4797b79bea13cd93","repo":"quickwit-oss/quickwit","slug":"1-is-always-non-zero","errorCode":null,"errorMessage":"1 is always non-zero.","messagePattern":"1 is always non-zero\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"quickwit/quickwit-storage/src/object_storage/azure_blob_storage.rs","lineNumber":347,"sourceCode":"\n        // Commit all uploaded blocks.\n        blob_client\n            .put_block_list(block_list)\n            .into_future()\n            .await\n            .map_err(AzureErrorWrapper::from)?;\n\n        Ok(())\n    }\n}\n\n#[async_trait]\nimpl Storage for AzureBlobStorage {\n    async fn check_connectivity(&self) -> anyhow::Result<()> {\n        if let Some(first_blob_result) = self\n            .container_client\n            .list_blobs()\n            .max_results(NonZeroU32::new(1u32).expect(\"1 is always non-zero.\"))\n            .into_stream()\n            .next()\n            .await\n        {\n            let _ = first_blob_result?;\n        }\n        Ok(())\n    }\n\n    #[instrument(name = \"storage.azure.put\", level = \"debug\", skip(self, payload), fields(payload_len = payload.len()))]\n    async fn put(\n        &self,\n        path: &Path,\n        payload: Box<dyn crate::PutPayload>,\n    ) -> crate::StorageResult<()> {\n        crate::metrics::OBJECT_STORAGE_PUT_TOTAL.inc();\n        let name = self.blob_name(path);\n        let total_len = payload.len();","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-storage/src/object_storage/azure_blob_storage.rs#L329-L365","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["No action needed: this panic is unreachable with the literal value 1.","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\"))?`)."],"exampleFix":"// before (only if limit becomes dynamic)\n.max_results(NonZeroU32::new(limit).expect(\"1 is always non-zero.\"))\n// after\n.max_results(NonZeroU32::new(limit)\n    .ok_or_else(|| anyhow::anyhow!(\"max_results must be greater than zero\"))?)","handlingStrategy":"validation","validationCode":"// Only relevant if the max_results value becomes dynamic\nif limit == 0 { return Err(anyhow::anyhow!(\"max_results must be greater than zero\")); }\nlet max_results = NonZeroU32::new(limit).unwrap();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never wire user or config input into NonZeroU32::new with an expect message written for a literal constant.","Prefer `.ok_or_else(|| anyhow!(...))?` for any NonZero* constructed from dynamic values."],"tags":["rust","unreachable-panic","azure-blob-storage"],"backgroundTag":"internal-invariant-violation","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}