{"record":{"id":"d1292eaa683bb76d","repo":"tracel-ai/burn","slug":"invalid-regex-pattern","errorCode":null,"errorMessage":"Invalid regex pattern","messagePattern":"Invalid regex pattern","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-store/src/burnpack.rs","lineNumber":303,"sourceCode":"\n    /// Set key remapper for tensor name transformations during loading\n    #[cfg(feature = \"std\")]\n    pub fn remap(mut self, remapper: KeyRemapper) -> Self {\n        self.remapper = remapper;\n        self\n    }\n\n    /// Add a single regex pattern for key remapping\n    #[cfg(feature = \"std\")]\n    pub fn with_remap_pattern<S1, S2>(mut self, from: S1, to: S2) -> Self\n    where\n        S1: AsRef<str>,\n        S2: Into<String>,\n    {\n        self.remapper = self\n            .remapper\n            .add_pattern(from.as_ref(), to.into())\n            .expect(\"Invalid regex pattern\");\n        self\n    }\n\n    /// Set the path filter\n    pub fn filter(mut self, filter: PathFilter) -> Self {\n        self.filter = Some(filter);\n        self\n    }\n\n    /// Get the bytes after writing (only valid for bytes mode after collecting)\n    pub fn get_bytes(&self) -> Result<Bytes, PackError> {\n        // `collect_from` caches the written bytes back into `self.mode` for bytes mode.\n        match &self.mode {\n            StoreMode::Bytes(Some(bytes)) => Ok(bytes.clone()),\n            _ => Err(PackError::IoError(\"No bytes available\".into())),\n        }\n    }\n","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-store/src/burnpack.rs#L285-L321","documentation":"Regex validation guard in `with_remap_pattern`: the `from` string is compiled as a regex for key remapping; an invalid pattern makes `Regex::new` fail and the builder panics instead of silently accepting a broken remapper.","triggerScenarios":"Thrown at crates/burn-store/src/burnpack.rs:303 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the pattern with `Regex::new` before passing it","Fix escaping of regex metacharacters (e.g., `.`, `(`, `*`) in the pattern","Use `add_pattern` with error handling for fallible construction"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}