{"record":{"id":"7e68d65d6cb2b5bd","repo":"tracel-ai/burn","slug":"invalid-regex-pattern-7e68d6","errorCode":null,"errorMessage":"Invalid regex pattern","messagePattern":"Invalid regex pattern","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-store/src/pytorch/store.rs","lineNumber":249,"sourceCode":"\n    /// Add a regex pattern to remap tensor names during load.\n    ///\n    /// # Example\n    /// ```rust,no_run\n    /// # use burn_store::PytorchStore;\n    /// let store = PytorchStore::from_file(\"model.pth\")\n    ///     .with_key_remapping(r\"^encoder\\.\", \"transformer.encoder.\")  // encoder.X -> transformer.encoder.X\n    ///     .with_key_remapping(r\"\\.gamma$\", \".weight\");               // X.gamma -> X.weight\n    /// ```\n    pub fn with_key_remapping(\n        mut self,\n        from_pattern: impl AsRef<str>,\n        to_pattern: impl Into<String>,\n    ) -> Self {\n        self.remapper = self\n            .remapper\n            .add_pattern(from_pattern, to_pattern)\n            .expect(\"Invalid regex pattern\");\n        self\n    }\n\n    /// Set whether to validate tensors during loading (default: true).\n    pub fn validate(mut self, validate: bool) -> Self {\n        self.validate = validate;\n        self\n    }\n\n    /// Allow partial loading of tensors (continue even if some tensors are missing).\n    pub fn allow_partial(mut self, allow: bool) -> Self {\n        self.allow_partial = allow;\n        self\n    }\n\n    /// Skip enum variant names when matching tensor paths (default: true).\n    ///\n    /// When enabled, tensor paths from PyTorch that don't include enum variants","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-store/src/pytorch/store.rs#L231-L267","documentation":"Regex validation guard in `PytorchStore::with_key_remapping`: the `from_pattern` is compiled as a regex for tensor-name remapping during load; an invalid pattern panics instead of producing a silently non-matching remapper.","triggerScenarios":"Thrown at crates/burn-store/src/pytorch/store.rs:249 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pre-validate the pattern with `Regex::new`","Fix regex escapes (e.g., `\\.` for literal dots) in the pattern","Test the pattern against expected key names before building the store"],"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"}