{"record":{"id":"a597839d78841bf3","repo":"can1357/oh-my-pi","slug":"invalid-argument","errorCode":null,"errorMessage":"invalid {} argument: {}","messagePattern":"invalid (.+?) argument: (.+?)","errorType":"error_code","errorClass":"SeqError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/seq.rs","lineNumber":433,"sourceCode":"\nmod error {\n//! Errors returned by seq.\n\n// pi-uutils: `translate!` message lookups are literalized with the en-US\n// strings from upstream's locales/en-US.ftl.\n\nuse thiserror::Error;\nuse uucore::display::Quotable;\n\nuse super::numberparse::ParseNumberError;\n\n#[derive(Debug, Error)]\npub enum SeqError {\n\t/// An error parsing the input arguments.\n\t///\n\t/// The parameters are the [`String`] argument as read from the\n\t/// command line and the underlying parsing error itself.\n\t#[error(\"invalid {} argument: {}\", parse_error_type(.1), .0.quote())]\n\tParseError(String, ParseNumberError),\n\n\t/// The increment argument was zero, which is not allowed.\n\t///\n\t/// The parameter is the increment argument as a [`String`] as read\n\t/// from the command line.\n\t#[error(\"invalid Zero increment value: {}\", .0.quote())]\n\tZeroIncrement(String),\n\n\t/// No arguments were passed to this function, 1 or more is required\n\t#[error(\"missing operand\")]\n\tNoArguments,\n\n\t/// Both a format and equal width where passed to seq\n\t#[error(\"format string may not be specified when printing equal width strings\")]\n\tFormatAndEqualWidth,\n}\n","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/seq.rs#L415-L451","documentation":"`SeqError::ParseError` from the seq builtin: an operand string could not be parsed as a number. The message is 'invalid {type} argument: {arg}' where the type comes from `parse_error_type(.1)` (e.g. floating-point vs integer) and the offending argument is quoted. It exists so the CLI can report exactly which command-line argument was malformed and why.","triggerScenarios":"Calling seq (or the library's seq entry point) with a non-numeric operand, e.g. `seq abc`, `seq 1 xyz 10`, arguments with stray whitespace or thousands separators ('1 000'), trailing characters ('10f'), or an empty string as one of start/increment/end operands.","commonSituations":"Shell variables that are unset or empty expanding to nothing (`seq $START 10` with START unset); passing floats to the integer-only form or vice versa; locale-formatted numbers ('1,5'); copy-pasted arguments with hidden Unicode characters; typos like `seq 1..10`.","solutions":["Inspect the quoted argument in the message and correct the typo so it is a plain integer or float depending on the seq form used.","Check that shell variables used as operands are set and numeric (`echo \"$START\"`, or `${START:-0}`).","Strip locale formatting: remove thousands separators and use '.' as the decimal separator.","In code calling the seq API, parse/validate operands yourself first and reject non-numeric strings with your own error before invoking seq.","Quote shell arguments to avoid word-splitting producing extra/empty operands (`seq \"$start\" \"$end\"`)."],"exampleFix":"// before: unset variable expands to an empty operand\nseq $START $END        # -> invalid floating-point argument: ''\n\n// after: default and validate before use\n: \"${START:=1}\"\nseq \"$START\" \"$END\"","handlingStrategy":"validation","validationCode":"fn validate_seq_operand(arg: &str) -> Result<f64, String> {\n    let t = arg.trim();\n    if t.is_empty() {\n        return Err(\"seq operand is empty (unset variable?)\".into());\n    }\n    t.parse::<f64>().map_err(|_| format!(\"invalid seq operand: {arg:?}\"))\n}","typeGuard":"fn is_parse_error(err: &SeqError) -> bool {\n    matches!(err, SeqError::ParseError(_, _))\n}","tryCatchPattern":"match seq_result {\n    Err(SeqError::ParseError(arg, kind)) => {\n        eprintln!(\"seq: fix argument {arg} (expected a number: {kind:?})\");\n    }\n    Err(e) => return Err(e.into()),\n    Ok(v) => Ok(v),\n}","preventionTips":["Always quote shell operands (`seq \"$start\" \"$end\"`) to prevent word-splitting and empty arguments.","Default or validate shell variables before use: `${START:=1}`.","Use '.' as decimal separator and strip thousands separators / locale formatting.","Pre-parse operands in calling code and reject non-numeric strings with your own error before invoking seq."],"tags":["argument-parsing","validation","cli","rust"],"backgroundTag":"invalid-argument","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}