{"record":{"id":"e079e49568c51248","repo":"DioxusLabs/dioxus","slug":"invalid-utf8-you-cannot-split-at-a-byte-that-is-n","errorCode":null,"errorMessage":"Invalid utf8; you cannot split at a byte that is not a char boundary","messagePattern":"Invalid utf8; you cannot split at a byte that is not a char boundary","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/const-serialize/src/str.rs","lineNumber":147,"sourceCode":"        let new_len = len as usize + str_bytes.len();\n        let mut i = 0;\n        while i < str_bytes.len() {\n            bytes[len as usize + i] = MaybeUninit::new(str_bytes[i]);\n            i += 1;\n        }\n        Self {\n            bytes,\n            len: new_len as u32,\n        }\n    }\n\n    /// Split the string at a byte index. The byte index must be a char boundary\n    pub const fn split_at(self, index: usize) -> (Self, Self) {\n        let (left, right) = self.bytes().split_at(index);\n        let left = match std::str::from_utf8(left) {\n            Ok(s) => s,\n            Err(_) => {\n                panic!(\"Invalid utf8; you cannot split at a byte that is not a char boundary\")\n            }\n        };\n        let right = match std::str::from_utf8(right) {\n            Ok(s) => s,\n            Err(_) => {\n                panic!(\"Invalid utf8; you cannot split at a byte that is not a char boundary\")\n            }\n        };\n        (Self::new(left), Self::new(right))\n    }\n\n    /// Split the string at the last occurrence of a character\n    pub const fn rsplit_once(&self, char: char) -> Option<(Self, Self)> {\n        let str = self.as_str();\n        let mut index = str.len() - 1;\n        // First find the bytes we are searching for\n        let (char_bytes, len) = char_to_bytes(char);\n        let (char_bytes, _) = char_bytes.split_at(len);","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/const-serialize/src/str.rs#L129-L165","documentation":"const_str's split_at tried to reinterpret the left byte slice as UTF-8 and failed because the requested index does not fall on a char boundary. The function's contract requires the index to be a boundary; passing one inside a multi-byte character triggers this panic in the const context.","triggerScenarios":"Thrown at packages/const-serialize/src/str.rs:147 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only split strings at a UTF-8 char boundary. Use char_indices() or floor_char_boundary() to find a valid index."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}