{"record":{"id":"5fc4817019e7cd05","repo":"astral-sh/ruff","slug":"valuevalidation","errorCode":null,"errorMessage":"ValueValidation","messagePattern":"ValueValidation","errorType":"validation","errorClass":"clap::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff/src/args.rs","lineNumber":1032,"sourceCode":"\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)));\n                    }\n                    InvalidConfigFlagReason::ExtendPassedViaConfigFlag\n                }\n                Err(underlying_error) => {\n                    InvalidConfigFlagReason::ValidTomlButInvalidRuffSchema(underlying_error)\n                }\n            },\n            Err(underlying_error) => InvalidConfigFlagReason::InvalidToml(underlying_error),\n        };\n\n        let mut new_error = clap::Error::new(clap::error::ErrorKind::ValueValidation).with_cmd(cmd);\n        if let Some(arg) = arg {\n            new_error.insert(\n                clap::error::ContextKind::InvalidArg,\n                clap::error::ContextValue::String(arg.to_string()),\n            );\n        }\n        new_error.insert(\n            clap::error::ContextKind::InvalidValue,\n            clap::error::ContextValue::String(value.to_string()),\n        );\n\n        let underlying_error = match &config_parse_error {\n            InvalidConfigFlagReason::ExtendPassedViaConfigFlag => {\n                let tip = config_parse_error.description().into();\n                new_error.insert(\n                    clap::error::ContextKind::Suggested,\n                    clap::error::ContextValue::StyledStrs(vec![tip]),\n                );","sourceCodeStart":1014,"sourceCodeEnd":1050,"githubUrl":"https://github.com/astral-sh/ruff/blob/15f3fe6b15a5f00172f34b0f542f8ea277f5a586/crates/ruff/src/args.rs#L1014-L1050","documentation":"This clap ValueValidation error is constructed manually by ruff's CLI when a `--config` flag value cannot be parsed as valid TOML, or parses as TOML but does not match ruff's configuration schema. Ruff intercepts config parsing failures and re-reports them as a structured clap error so they surface as normal CLI argument errors. The message carries an `InvalidArg` context naming the offending flag.","triggerScenarios":"Passing `--config` / `--config-file` with a malformed TOML file, or a TOML file whose contents fail ruff's schema validation (e.g. wrong type for a setting, unknown key with strict parsing).","commonSituations":"Typos in config keys, editing pyproject.toml/ruff.toml by hand and introducing invalid TOML, copying config between projects where a setting's type changed across ruff versions.","solutions":["Validate the config file by running the same file through `ruff check --config path` or a TOML linter to locate the syntax/schema error","Fix the TOML syntax error reported (missing quotes, trailing commas, wrong types)","Pin/consult the ruff docs for your installed version to ensure the keys exist and have valid types","If embedding config inline, ensure the value is valid TOML for the schema"],"exampleFix":"// before (invalid TOML)\n# ruff.toml\n[lint]\nselect = E4  // not valid TOML\n// after\n[lint]\nselect = [\"E4\"]","handlingStrategy":"validation","validationCode":"import tomllib\nfrom pathlib import Path\ntry:\n    tomllib.loads(Path(\"ruff.toml\").read_text())\nexcept tomllib.TOMLDecodeError as e:\n    raise SystemExit(f\"invalid ruff config TOML: {e}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate config TOML in CI before running ruff","Use a TOML-aware editor plugin to catch syntax errors on save","Keep config keys matched to your installed ruff version's schema"],"tags":["cli","config","toml"],"backgroundTag":"invalid-config-value","analyzedSha":"15f3fe6b15a5f00172f34b0f542f8ea277f5a586","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}