{"record":{"id":"fbec5254a856fc55","repo":"quickwit-oss/quickwit","slug":"the-regular-expression-should-compile","errorCode":null,"errorMessage":"The regular expression should compile.","messagePattern":"The regular expression should compile\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"quickwit/quickwit-storage/src/object_storage/azure_blob_storage.rs","lineNumber":589,"sourceCode":") -> ContainerClient {\n    let mut builder = ClientBuilder::new(storage_account_name.clone(), storage_credentials);\n    if let Some(uri) = blob_service_uri {\n        info!(endpoint=%uri, \"using Azure blob storage endpoint defined in storage config or environment variable\");\n        builder = builder.cloud_location(CloudLocation::Custom {\n            account: storage_account_name,\n            uri,\n        });\n    }\n    builder\n        .blob_service_client()\n        .container_client(container_name)\n}\n\npub fn parse_azure_uri(uri: &Uri) -> Option<(String, PathBuf)> {\n    // Ex: azure://container/prefix.\n    static URI_PTN: LazyLock<Regex> = LazyLock::new(|| {\n        Regex::new(r\"azure(\\+[^:]+)?://(?P<container>[^/]+)(/(?P<prefix>.+))?\")\n            .expect(\"The regular expression should compile.\")\n    });\n\n    let captures = URI_PTN.captures(uri.as_str())?;\n\n    let container = captures.name(\"container\")?.as_str().to_string();\n    let prefix = captures\n        .name(\"prefix\")\n        .map(|prefix_match| PathBuf::from(prefix_match.as_str()))\n        .unwrap_or_default();\n    Some((container, prefix))\n}\n\n/// Collect a download stream into a single [`Bytes`].\n///\n/// `Bytes` segments yielded by the SDK are preserved so that the single-segment case avoids the\n/// extra copy into a contiguous buffer. When more than one segment is received, they are\n/// concatenated exactly once into a freshly allocated `Bytes`.\nasync fn download_all(","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-storage/src/object_storage/azure_blob_storage.rs#L571-L607","documentation":"This panic fires from `.expect()` on `Regex::new` inside `parse_azure_uri`, which matches URIs of the form `azure://container/prefix`. The pattern is a static constant and is known to compile, so the expect documents that a bad regex is a programming error, not a runtime condition. A `None` from this function normally means the URI simply did not match the azure scheme.","triggerScenarios":"Only if the static regex literal is edited to an invalid pattern (e.g. an unbalanced parenthesis or bad escape during a code change), causing `Regex::new` to return `Err`. Passing a non-azure URI never triggers it — that path returns `None` via `captures(...)?`.","commonSituations":"Not hit by library users. Developers contributing to quickwit encounter this pattern when modifying the URI regex in `parse_azure_uri`; a typo in the pattern panics on the first `LazyLock` initialization.","solutions":["No runtime fix needed: the shipped regex compiles.","If editing the pattern, run `cargo test -p quickwit-storage test_parse_azure_uri` to force initialization and catch a broken regex immediately.","For user-supplied regexes elsewhere, use `Regex::new(p).map_err(...)` instead of expect."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Callers: treat None as an unsupported URI scheme before using the storage\nlet (container, path) = parse_azure_uri(&uri)\n    .ok_or_else(|| anyhow::anyhow!(\"not a valid azure storage URI: {}\", uri))?;","typeGuard":"fn is_azure_uri(uri: &Uri) -> bool {\n    uri.scheme_str().map(|s| s.starts_with(\"azure\")).unwrap_or(false)\n}","tryCatchPattern":"// The expect panics rather than returning an error; guard by checking the scheme first\nif !is_azure_uri(&uri) { bail!(\"URI is not azure://, cannot build AzureBlobStorage\"); }","preventionTips":["Validate URI schemes before constructing storage backends from user config.","Keep regexes static and run the parse unit tests after any pattern edit.","Never build a Regex from runtime/user input with expect."],"tags":["rust","regex","unreachable-panic","azure-uri"],"backgroundTag":"invalid-regex-pattern","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"}