{"record":{"id":"59d95245fbb5947d","repo":"astral-sh/ruff","slug":"invalidutf8","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/args.rs","lineNumber":1003,"sourceCode":"}\n\nimpl TypedValueParser for ConfigArgumentParser {\n    type Value = SingleConfigArgument;\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        // Convert to UTF-8.\n        let Some(value) = value.to_str() else {\n            // But respect non-UTF-8 paths.\n            let path_to_config_file = PathBuf::from(value);\n            if path_to_config_file.is_file() {\n                return Ok(SingleConfigArgument::FilePath(path_to_config_file));\n            }\n            return Err(clap::Error::new(clap::error::ErrorKind::InvalidUtf8));\n        };\n\n        // Expand environment variables and tildes.\n        if let Ok(path_to_config_file) =\n            shellexpand::full(value).map(|config| PathBuf::from(&*config))\n        {\n            if path_to_config_file.is_file() {\n                return Ok(SingleConfigArgument::FilePath(path_to_config_file));\n            }\n        }\n\n        let _guard = ValueSourceGuard::new(ValueSource::Cli, false);\n\n        let config_parse_error = match toml::Table::from_str(value) {\n            Ok(table) => match Options::from_toml_table(table) {\n                Ok(option) => {\n                    if option.extend.is_none() {\n                        return Ok(SingleConfigArgument::SettingsOverride(Arc::new(option)));","sourceCodeStart":985,"sourceCodeEnd":1021,"githubUrl":"https://github.com/astral-sh/ruff/blob/d1087a4b9e03d253a88703f34e0869ee4b805456/crates/ruff/src/args.rs#L985-L1021","documentation":"The `--config` value parser accepts either a path to an existing config file (which may legitimately be non-UTF-8 at the OS level) or an inline UTF-8 TOML string. If the raw argument is not valid UTF-8 AND the bytes do not name an existing file, clap fails with ErrorKind::InvalidUtf8 and this default message.","triggerScenarios":"`ruff check --config <non-UTF-8 bytes>` where no file exists at those bytes — a mis-encoded path typed in a legacy-locale terminal, or a config file that was renamed or deleted.","commonSituations":"Terminal/locale mismatches producing Latin-1 filenames; scripts piping raw bytes into argv; referring to a moved config file by its old name.","solutions":["Verify the exact bytes being passed (`printf '%s' \"$cfg\" | xxd`) and that a file exists at that path.","Re-enter the path in a UTF-8 locale (`export LANG=C.UTF-8`) so the shell produces UTF-8 bytes.","Rename the config file to a valid-UTF-8 name and reference that.","Alternatively pass settings inline as UTF-8 TOML, e.g. `--config 'line-length = 100'`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/bin/sh\ncfg=\"$1\"\nif ! printf '%s' \"$cfg\" | iconv -f UTF-8 -t UTF-8 >/dev/null 2>&1 && [ ! -e \"$cfg\" ]; then\n  echo \"--config value is not UTF-8 and no file exists at that path\" >&2\n  exit 1\nfi\nexec ruff check --config \"$cfg\" .","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run terminals/CI in a UTF-8 locale (LANG=C.UTF-8).","Prefer ASCII or UTF-8 names for config files.","Quote config paths so the shell passes them unchanged."],"tags":["ruff","cli","utf-8","config","args"],"backgroundTag":"cli-invalid-utf8","analyzedSha":"d1087a4b9e03d253a88703f34e0869ee4b805456","analyzedAt":"2026-08-20T16:33:49.445Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}