{"record":{"id":"20fd42828b141a07","repo":"risingwavelabs/risingwave","slug":"invalid-unit-0","errorCode":null,"errorMessage":"Invalid unit: {0}","messagePattern":"Invalid unit: (.+?)","errorType":"validation","errorClass":"IntervalParseError","httpStatus":null,"severity":"error","filePath":"src/common/src/types/interval.rs","lineNumber":1024,"sourceCode":"        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 {\n        // ISO pattern - PnYnMnDTnHnMnS\n        let years = self.months / 12;\n        let months = self.months % 12;\n        let days = self.days;\n        let secs_fract = (self.usecs % USECS_PER_SEC).abs();\n        let total_secs = (self.usecs / USECS_PER_SEC).abs();\n        let hours = total_secs / 3600;\n        let minutes = (total_secs / 60) % 60;","sourceCodeStart":1006,"sourceCodeEnd":1042,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/common/src/types/interval.rs#L1006-L1042","documentation":"IntervalParseError::InvalidUnit comes from DateTimeField::from_str: the word following a number in an interval literal is not a recognized time unit. Accepted (case-insensitive) units are year(s)/yr(s)/y, day(s)/d, hour(s)/hr(s)/h, minute(s)/min(s)/m, month(s)/mon(s), second(s)/sec(s)/s.","triggerScenarios":"Interval literals with misspelled or unsupported units: '3 weeks', '5 fortnights', '2 yrs.' (trailing period), or abbreviations not in the table like 'ms' or 'w'.","commonSituations":"Migrating from systems with richer unit vocab (weeks, microseconds); typos ('monts'); locale-translated unit names in generated SQL.","solutions":["Replace the unit with a supported one: year, month, day, hour, minute, second or their listed abbreviations.","Convert weeks manually (1 week = 7 days) and microseconds/seconds fractions accordingly.","Strip trailing punctuation like '.' from generated unit tokens before parsing."],"exampleFix":"// before\nlet iv: Interval = \"3 weeks\".parse()?;\n// after\nlet iv: Interval = \"21 days\".parse()?;","handlingStrategy":"validation","validationCode":"const UNITS: &[&str] = &[\"year\",\"years\",\"yr\",\"yrs\",\"y\",\"day\",\"days\",\"d\",\"hour\",\"hours\",\"hr\",\"hrs\",\"h\",\"minute\",\"minutes\",\"min\",\"mins\",\"m\",\"month\",\"months\",\"mon\",\"mons\",\"second\",\"seconds\",\"sec\",\"secs\",\"s\"];\nfn is_known_unit(u: &str) -> bool { UNITS.contains(&u.to_lowercase().as_str()) }","typeGuard":"fn is_supported_interval_unit(u: &str) -> bool {\n    matches!(u.to_lowercase().as_str(), \"y\" | \"yr\" | \"yrs\" | \"year\" | \"years\" | \"d\" | \"day\" | \"days\" | \"h\" | \"hr\" | \"hrs\" | \"hour\" | \"hours\" | \"m\" | \"min\" | \"mins\" | \"minute\" | \"minutes\" | \"mon\" | \"mons\" | \"month\" | \"months\" | \"s\" | \"sec\" | \"secs\" | \"second\" | \"seconds\")\n}","tryCatchPattern":"let unit = DateTimeField::from_str(u)\n    .map_err(|e| anyhow!(\"unknown interval unit '{u}': {e}\"))?;","preventionTips":["Map richer unit vocabularies (weeks, ms) to supported units before parsing.","Strip trailing punctuation from generated unit tokens.","Keep a central allow-list of unit spellings in code generators."],"tags":["rust","interval","parsing","unit"],"backgroundTag":"invalid-enum-value","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"}