{"record":{"id":"7f7db2b11e68baa2","repo":"theonedev/onedev","slug":"malformed-retry-condition","errorCode":null,"errorMessage":"Malformed retry condition","messagePattern":"Malformed retry condition","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/job/retrycondition/RetryCondition.java","lineNumber":78,"sourceCode":"\t@Override\n\tpublic Predicate getPredicate(@Nullable ProjectScope projectScope, CriteriaQuery<?> query, From<RetryContext, RetryContext> from, CriteriaBuilder builder) {\n\t\tthrow new UnsupportedOperationException();\n\t}\n\t\n\tpublic boolean matches(RetryContext context) {\n\t\treturn criteria.matches(context);\n\t}\n\t\n\tpublic static RetryCondition parse(Job job, String conditionString) {\n\t\tCharStream is = CharStreams.fromString(conditionString); \n\t\tRetryConditionLexer lexer = new RetryConditionLexer(is);\n\t\tlexer.removeErrorListeners();\n\t\tlexer.addErrorListener(new BaseErrorListener() {\n\n\t\t\t@Override\n\t\t\tpublic void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,\n\t\t\t\t\tint charPositionInLine, String msg, RecognitionException e) {\n\t\t\t\tthrow new RuntimeException(\"Malformed retry condition\", e);\n\t\t\t}\n\t\t\t\n\t\t});\n\t\tCommonTokenStream tokens = new CommonTokenStream(lexer);\n\t\tRetryConditionParser parser = new RetryConditionParser(tokens);\n\t\tparser.removeErrorListeners();\n\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\tConditionContext conditionContext = parser.condition();\n\n\t\tCriteria<RetryContext> criteria;\n\t\t\n\t\tif (conditionContext.Never() != null) {\n\t\t\tcriteria = new NeverCriteria();\n\t\t} else {\n\t\t\tcriteria = new RetryConditionBaseVisitor<Criteria<RetryContext>>() {\n\t\n\t\t\t\t@Override\n\t\t\t\tpublic Criteria<RetryContext> visitParensCriteria(ParensCriteriaContext ctx) {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/job/retrycondition/RetryCondition.java#L60-L96","documentation":"Thrown by RetryCondition's ANTLR syntaxError listener when a retry condition string fails to parse against the retry condition grammar. It wraps the ANTLR RecognitionException in a RuntimeException, so the cause chain contains position and offending-symbol details.","triggerScenarios":"A retry condition expression in the job spec with invalid syntax — misspelled keywords, unbalanced quotes, or tokens not in the grammar (e.g. bad operator names for 'error message'/'failure reason' criteria).","commonSituations":"Hand-writing retry conditions in buildspec.yml; quoting mistakes around error-message patterns; copy-paste artifacts like smart quotes.","solutions":["Inspect the Caused-by RecognitionException for line/char and offending token.","Fix quoting and keyword spelling per the retry condition grammar.","Simplify the condition and rebuild it incrementally, testing after each addition."],"exampleFix":"// before\nretry condition: error message contains 'connection reset'\n\n// after (valid quoting/syntax)\nretry condition: error message contains 'connection reset' && attempt < 3","handlingStrategy":"try-catch","validationCode":"try {\n    RetryCondition.parse(conditionText);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Malformed retry condition\")) {\n        // surface RecognitionException details (line/char) for the author\n    } else throw e;\n}","typeGuard":null,"tryCatchPattern":"try {\n    RetryCondition.parse(text);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    throw new IllegalArgumentException(\"Invalid retry condition '\" + text + \"': \" + (cause != null ? cause.getMessage() : e.getMessage()), e);\n}","preventionTips":["Incrementally build retry conditions and test-parse each addition.","Use single quotes for string patterns; escape embedded quotes.","Check the cause chain for the exact offending token."],"tags":["onedev","parser","retry-condition","buildspec"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}