{"id":"054d0a4709e58703","repo":"BurntSushi/ripgrep","slug":"separator-must-be-valid-utf-8-use-escape-sequence","errorCode":null,"errorMessage":"separator must be valid UTF-8 (use escape sequences to provide a separator that is not valid UTF-8)","messagePattern":"separator must be valid UTF-8 \\(use escape sequences to provide a separator that is not valid UTF-8\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/flags/lowargs.rs","lineNumber":497,"sourceCode":"/// Represents the separator to use between non-contiguous sections of\n/// contextual lines.\n///\n/// The default is `--`.\n#[derive(Clone, Debug, Eq, PartialEq)]\npub(crate) struct ContextSeparator(Option<BString>);\n\nimpl Default for ContextSeparator {\n    fn default() -> ContextSeparator {\n        ContextSeparator(Some(BString::from(\"--\")))\n    }\n}\n\nimpl ContextSeparator {\n    /// Create a new context separator from the user provided argument. This\n    /// handles unescaping.\n    pub(crate) fn new(os: &OsStr) -> anyhow::Result<ContextSeparator> {\n        let Some(string) = os.to_str() else {\n            anyhow::bail!(\n                \"separator must be valid UTF-8 (use escape sequences \\\n                 to provide a separator that is not valid UTF-8)\"\n            )\n        };\n        Ok(ContextSeparator(Some(Vec::unescape_bytes(string).into())))\n    }\n\n    /// Creates a new separator that instructs the printer to disable contextual\n    /// separators entirely.\n    pub(crate) fn disabled() -> ContextSeparator {\n        ContextSeparator(None)\n    }\n\n    /// Return the raw bytes of this separator.\n    ///\n    /// If context separators were disabled, then this returns `None`.\n    ///\n    /// Note that this may return a `Some` variant with zero bytes.","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/BurntSushi/ripgrep/blob/3fce3b5bb0236da2df6d99672afb8a719642eca7/crates/core/flags/lowargs.rs#L479-L515","documentation":"Error \"separator must be valid UTF-8 (use escape sequences to provide a separator that is not valid UTF-8)\" thrown in BurntSushi/ripgrep.","triggerScenarios":"Thrown at crates/core/flags/lowargs.rs:497 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a separator that is valid UTF-8","Provide arbitrary bytes via escape sequences for the separator"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"3fce3b5bb0236da2df6d99672afb8a719642eca7","analyzedAt":"2026-08-06T01:39:05.073Z","schemaVersion":2}