{"record":{"id":"1fe78c07ab88935b","repo":"quarkusio/quarkus","slug":"invalid-regex-pattern-stringvalue-in-annotati","errorCode":null,"errorMessage":"Invalid regex pattern '<stringValue>' in <annotation>: <e.getMessage()>","messagePattern":"Invalid regex pattern '<stringValue>' in <annotation>: <e\\.getMessage\\(\\)>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/LookupConditionsProcessor.java","lineNumber":258,"sourceCode":"            }\n        }));\n    }\n\n    private static StringValueMatch getMatch(AnnotationInstance annotation) {\n        AnnotationValue matchValue = annotation.value(MATCH);\n        if (matchValue != null) {\n            return StringValueMatch.valueOf(matchValue.asEnum());\n        }\n        return StringValueMatch.EQ;\n    }\n\n    private static void validateRegex(AnnotationInstance annotation) {\n        if (getMatch(annotation) == StringValueMatch.REGEX) {\n            String stringValue = annotation.value(STRING_VALUE).asString();\n            try {\n                Pattern.compile(stringValue);\n            } catch (PatternSyntaxException e) {\n                throw new IllegalArgumentException(\n                        \"Invalid regex pattern '\" + stringValue + \"' in \" + annotation + \": \" + e.getMessage(), e);\n            }\n        }\n    }\n}\n","sourceCodeStart":240,"sourceCodeEnd":264,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/LookupConditionsProcessor.java#L240-L264","documentation":"Lookup conditions (@LookupCondition/@LookupNotCondition style annotations) can match strings by REGEX. validateRegex compiles the pattern at build time and wraps any PatternSyntaxException in an IllegalArgumentException including the annotation, the bad pattern and the regex error message.","triggerScenarios":"An annotation with match = REGEX whose 'stringValue' attribute is not a compilable regex — e.g. unbalanced parentheses, dangling quantifier, bad character class — declared on a bean or lookup point.","commonSituations":"Hand-written regex typos in @LookupCondition(value=\"[foo\", match=REGEX); dynamically composed patterns with unescaped user input; patterns written for another regex flavor.","solutions":["Fix the regex in the annotation's stringValue attribute","Test the pattern with Pattern.compile() in a scratch main or unit test","Use StringValueMatch.EQUALS or PREFIX instead of REGEX if simple matching suffices"],"exampleFix":"// before\n@LookupCondition(stringValue = \"[com.acme\", match = StringValueMatch.REGEX)\n// after\n@LookupCondition(stringValue = \"com\\\\.acme\\\\..*\", match = StringValueMatch.REGEX)","handlingStrategy":"validation","validationCode":"String p = \"com\\\\.acme\\\\..*\";\ntry { Pattern.compile(p); } catch (PatternSyntaxException e) { throw new IllegalArgumentException(\"Bad regex in @LookupCondition: \" + p, e); }","typeGuard":null,"tryCatchPattern":"try {\n    app.start();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid regex pattern\")) {\n        log.error(e.getMessage()); // fix the annotation's stringValue\n    } else throw e;\n}","preventionTips":["Unit-test every regex constant used in lookup conditions","Prefer EQUALS/PREFIX matches when regex is unnecessary","Escape dots and special characters in package patterns"],"tags":["quarkus","arc","regex","build-time"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}