{"record":{"id":"8eb3ca1d2bd8a077","repo":"risingwavelabs/risingwave","slug":"invalid-regular-expression-option-c","errorCode":null,"errorMessage":"invalid regular expression option: \"{c}\"","messagePattern":"invalid regular expression option: \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/expr/impl/src/scalar/regexp.rs","lineNumber":129,"sourceCode":"    /// `g`\n    global: bool,\n}\n\nimpl FromStr for RegexpOptions {\n    type Err = ExprError;\n\n    fn from_str(s: &str) -> Result<Self> {\n        let mut opts = Self::default();\n        for c in s.chars() {\n            match c {\n                // Case sensitive matching here\n                'c' => opts.case_insensitive = false,\n                // Case insensitive matching here\n                'i' => opts.case_insensitive = true,\n                // Global matching here\n                'g' => opts.global = true,\n                _ => {\n                    bail!(\"invalid regular expression option: \\\"{c}\\\"\");\n                }\n            }\n        }\n        Ok(opts)\n    }\n}\n\n#[function(\n    // source ~ pattern\n    \"regexp_eq(varchar, varchar) -> boolean\",\n    prebuild = \"RegexpContext::from_pattern($1)?\"\n)]\nfn regexp_eq(text: &str, regex: &RegexpContext) -> bool {\n    regex.regex.is_match(text).unwrap()\n}\n\n#[function(\n    // regexp_match(source, pattern)","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/expr/impl/src/scalar/regexp.rs#L111-L147","documentation":"RisingWave parses a regex flags string character-by-character into `RegexpOptions` (case_insensitive, global, etc.). Any character other than the supported option letters is rejected with this error, since there is no silent-tolerance policy for unknown flags.","triggerScenarios":"Passing a flags string to any regex function (regexp_match/replace/count/etc., or `RegexpOptions::from_str`) containing an unsupported character, e.g. 'x' (extended), 's', 'm' (multiline is 'm'? — only supported single-char options pass), or whitespace/typos.","commonSituations":"Porting regex flags from other engines (Postgres 'ng', PCRE 'x', JS 's'), typos like 'gg' or accidental spaces in the flag literal.","solutions":["Use only supported flags: 'i' (case-insensitive), 'c' (case-sensitive), 'g' (global)","Remove unsupported flags such as 'x', 's', 'n' from the flags string","Rewrite the pattern to achieve the flag's effect (e.g. use (?s) inline constructs if supported by the regex crate)"],"exampleFix":"-- before\nSELECT regexp_replace(s, 'a', 'b', 'x');\n-- after\nSELECT regexp_replace(s, 'a', 'b', 'g');","handlingStrategy":"validation","validationCode":"const ok = /^[icg]*$/.test(flags); if (!ok) throw new Error(`unsupported regex flags: ${flags}`);","typeGuard":null,"tryCatchPattern":"try { await rw.query(sql) } catch (e) { if (String(e).includes('invalid regular expression option')) { /* sanitize flags and retry */ } else throw e; }","preventionTips":["Restrict flags to i, c, g when generating SQL","Sanitize user-supplied flags before interpolation","Avoid porting engine-specific flags (x, s, n) directly"],"tags":["sql","regex","invalid-argument"],"backgroundTag":"invalid-flag-value","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}