{"record":{"id":"bc8319c8b2a5cdc2","repo":"risingwavelabs/risingwave","slug":"invalid-interval-0","errorCode":null,"errorMessage":"Invalid interval: {0}","messagePattern":"Invalid interval: (.+?)","errorType":"validation","errorClass":"IntervalParseError","httpStatus":null,"severity":"error","filePath":"src/common/src/types/interval.rs","lineNumber":1016,"sourceCode":"}\n\nimpl ToText for crate::types::Interval {\n    fn write<W: std::fmt::Write>(&self, f: &mut W) -> std::fmt::Result {\n        write!(f, \"{self}\")\n    }\n\n    fn write_with_type<W: std::fmt::Write>(&self, ty: &DataType, f: &mut W) -> std::fmt::Result {\n        match ty {\n            DataType::Interval => self.write(f),\n            _ => unreachable!(),\n        }\n    }\n}\n\n/// Error type for parsing an [`Interval`].\n#[derive(thiserror::Error, Debug, thiserror_ext::Construct)]\npub enum IntervalParseError {\n    #[error(\"Invalid interval: {0}\")]\n    Invalid(String),\n\n    #[error(\n        \"Invalid interval: {0}, expected format P<years>Y<months>M<days>DT<hours>H<minutes>M<seconds>S\"\n    )]\n    InvalidIso8601(String),\n\n    #[error(\"Invalid unit: {0}\")]\n    InvalidUnit(String),\n\n    #[error(\"{0}\")]\n    Uncategorized(String),\n}\n\ntype ParseResult<T> = std::result::Result<T, IntervalParseError>;\n\nimpl Interval {\n    pub fn as_iso_8601(&self) -> String {","sourceCodeStart":998,"sourceCodeEnd":1034,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/common/src/types/interval.rs#L998-L1034","documentation":"IntervalParseError::Invalid is the generic failure of Interval's PostgreSQL-style text parser: the token stream did not yield a valid (years, months, days, usecs) tuple. Raised by parse_interval when a numeric buffer can't parse as i64 (convert_digit), an 'HH:MM:SS' segment is malformed, or the ':' appears without a preceding digit.","triggerScenarios":"'1 year 2 foo' (unknown trailing token), 'abc' (non-numeric), ':' at start (' :30'), malformed clock part ('1:2:3:4'), or huge numbers overflowing i64 via Interval::from_str / parse_interval.","commonSituations":"Hand-written SQL intervals with typos ('2 weaks'); copying intervals from other systems whose syntax differs; values with separators the tokenizer doesn't accept (commas: '1,000 days').","solutions":["Follow PostgreSQL interval syntax: '[<n> years] [<n> mons] [<n> days] [HH:MM:SS]'.","Remove unsupported characters (commas, brackets); use space or unit-letter separators.","For machine-readable exchange, use ISO 8601 duration format (P1Y2M3DT4H5M6S) which gets a more specific error."],"exampleFix":"// before\nlet iv: Interval = \"1,000 days\".parse()?;\n// after\nlet iv: Interval = \"1000 days\".parse()?;","handlingStrategy":"validation","validationCode":"fn is_pg_style_interval(s: &str) -> bool {\n    s.split_whitespace().all(|tok| {\n        tok.chars().next().map(|c| c.is_ascii_digit() || c == '-' || c == '+' || c == ':' || c.is_ascii_alphabetic()).unwrap_or(false)\n    })\n}","typeGuard":"fn looks_like_interval(s: &str) -> bool {\n    !s.trim().is_empty()\n        && s.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '+' | '.' | ':' | ' '))\n}","tryCatchPattern":"let iv = Interval::from_str(s)\n    .map_err(|e| anyhow!(\"invalid interval '{s}': {e}\"))?;","preventionTips":["Stick to PostgreSQL interval syntax in literals and generated SQL.","Avoid thousand separators and stray punctuation in numeric parts.","Prefer ISO 8601 durations for machine-generated interval strings."],"tags":["rust","interval","parsing","postgres"],"backgroundTag":"invalid-argument-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}