{"record":{"id":"68d2ede3d344a8b0","repo":"prestodb/presto","slug":"invalid-function-argument-68d2ed","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"INVALID_FUNCTION_ARGUMENT: e (invalid regexp pattern, message carried from joni exception)","messagePattern":"INVALID_FUNCTION_ARGUMENT: e \\(invalid regexp pattern, message carried from joni exception\\)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/scalar/JoniRegexpCasts.java","lineNumber":62,"sourceCode":"    }\n\n    @ScalarOperator(OperatorType.CAST)\n    @LiteralParameters(\"x\")\n    @SqlType(JoniRegexpType.NAME)\n    public static Regex castCharToJoniRegexp(@LiteralParameter(\"x\") Long charLength, @SqlType(\"char(x)\") Slice pattern)\n    {\n        return joniRegexp(padSpaces(pattern, charLength.intValue()));\n    }\n\n    public static Regex joniRegexp(Slice pattern)\n    {\n        Regex regex;\n        try {\n            // When normal UTF8 encoding instead of non-strict UTF8) is used, joni can infinite loop when invalid UTF8 slice is supplied to it.\n            regex = new Regex(pattern.getBytes(), 0, pattern.length(), Option.DEFAULT, NonStrictUTF8Encoding.INSTANCE, Syntax.Java);\n        }\n        catch (Exception e) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e);\n        }\n        return regex;\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":67,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/scalar/JoniRegexpCasts.java#L44-L67","documentation":"Raised in joniRegexp when constructing a joni Regex from the pattern slice fails: the joni library threw (syntax error, unsupported construct, or invalid UTF-8 bytes), and the original joni message is carried through so the faulty pattern text can be identified. Fired from castVarcharToJoniRegexp/castCharToJoniRegexp when casting a string to the Joni regexp type.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/scalar/JoniRegexpCasts.java:62 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the regexp pattern syntax (check for unbalanced parentheses, quantifiers with nothing to repeat, etc.)","Validate the pattern with regexp_like on a sample before casting","Ensure the input string is valid UTF-8"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}