{"record":{"id":"efbd062586120cb8","repo":"astral-sh/ruff","slug":"invalidutf8-efbd06","errorCode":"InvalidUtf8","errorMessage":"invalid UTF-8 was detected in one or more arguments","messagePattern":"invalid UTF-8 was detected in one or more arguments","errorType":"validation","errorClass":"clap::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff/src/commands/completions/config.rs","lineNumber":121,"sourceCode":"    type Parser = OptionStringParser;\n\n    fn value_parser() -> Self::Parser {\n        OptionStringParser\n    }\n}\n\nimpl TypedValueParser for OptionStringParser {\n    type Value = OptionString;\n\n    fn parse_ref(\n        &self,\n        cmd: &clap::Command,\n        arg: Option<&clap::Arg>,\n        value: &std::ffi::OsStr,\n    ) -> Result<Self::Value, clap::Error> {\n        let value = value\n            .to_str()\n            .ok_or_else(|| clap::Error::new(clap::error::ErrorKind::InvalidUtf8))?;\n\n        value.parse().map_err(|()| {\n            let mut error = clap::Error::new(clap::error::ErrorKind::ValueValidation).with_cmd(cmd);\n            if let Some(arg) = arg {\n                error.insert(\n                    clap::error::ContextKind::InvalidArg,\n                    clap::error::ContextValue::String(arg.to_string()),\n                );\n            }\n            error.insert(\n                clap::error::ContextKind::InvalidValue,\n                clap::error::ContextValue::String(value.to_string()),\n            );\n            error\n        })\n    }\n\n    fn possible_values(&self) -> Option<Box<dyn Iterator<Item = PossibleValue> + '_>> {","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/astral-sh/ruff/blob/d1087a4b9e03d253a88703f34e0869ee4b805456/crates/ruff/src/commands/completions/config.rs#L103-L139","documentation":"The `ruff option` command (an opaque command used to drive shell completions for option names) parses its OPTION argument with OptionStringParser, which requires the raw OsStr to be valid UTF-8 before matching it against ruff's options metadata. Non-UTF-8 bytes fail immediately with ErrorKind::InvalidUtf8.","triggerScenarios":"Passing a non-UTF-8 byte sequence as the OPTION argument of `ruff option`, e.g. a garbled key produced by a terminal in a legacy locale or a completion script consuming corrupted input.","commonSituations":"Practically never hit interactively; occurs in scripts with locale problems or corrupted input feeding the completion machinery.","solutions":["Re-run in a UTF-8 locale (`export LANG=C.UTF-8`).","Fix the script that produces the option name so it emits UTF-8.","Invoke the command as the generated completion scripts do — with typed text from the shell."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/bin/sh\nopt=\"$1\"\nprintf '%s' \"$opt\" | iconv -f UTF-8 -t UTF-8 >/dev/null 2>&1 || { echo \"option name is not UTF-8\" >&2; exit 1; }\nexec ruff option \"$opt\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run shells with a UTF-8 locale.","Regenerate completions with `ruff generate-completions` instead of hand-feeding `ruff option`."],"tags":["ruff","cli","utf-8","completions","args"],"backgroundTag":"cli-invalid-utf8","analyzedSha":"d1087a4b9e03d253a88703f34e0869ee4b805456","analyzedAt":"2026-08-20T16:33:49.445Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}