{"record":{"id":"aad3d1bb3b8339d5","repo":"theonedev/onedev","slug":"malformed-action-condition","errorCode":null,"errorMessage":"Malformed action condition","messagePattern":"Malformed action condition","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/job/action/condition/ActionCondition.java","lineNumber":82,"sourceCode":"\tpublic static String getValue(String token) {\n\t\treturn StringUtils.unescape(FenceAware.unfence(token));\n\t}\n\t\n\t@Override\n\tpublic boolean matches(Build build) {\n\t\treturn criteria.matches(build);\n\t}\n\t\n\tpublic static ActionCondition parse(Job job, String conditionString) {\n\t\tCharStream is = CharStreams.fromString(conditionString); \n\t\tActionConditionLexer lexer = new ActionConditionLexer(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 action condition\", e);\n\t\t\t}\n\t\t\t\n\t\t});\n\t\tCommonTokenStream tokens = new CommonTokenStream(lexer);\n\t\tActionConditionParser parser = new ActionConditionParser(tokens);\n\t\tparser.removeErrorListeners();\n\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\tConditionContext conditionContext = parser.condition();\n\n\t\tCriteria<Build> criteria;\n\t\t\n\t\tif (conditionContext.Always() != null) {\n\t\t\tcriteria = new AlwaysCriteria();\n\t\t} else {\n\t\t\tcriteria = new ActionConditionBaseVisitor<Criteria<Build>>() {\n\t\n\t\t\t\t@Override\n\t\t\t\tpublic Criteria<Build> visitParensCriteria(ParensCriteriaContext ctx) {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/job/action/condition/ActionCondition.java#L64-L100","documentation":"Thrown by ActionCondition.syntaxError listener when the ANTLR lexer/parser fails to parse an action condition expression. It is a plain RuntimeException wrapping the ANTLR RecognitionException, meaning the condition text does not conform to the action condition grammar.","triggerScenarios":"Passing a syntactically invalid condition string to ActionCondition.parse — e.g. unbalanced quotes or parentheses, unknown tokens, misspelled operator keywords, or dangling expressions.","commonSituations":"Hand-editing the job condition in buildspec.yml; copying conditions from docs with wrong quoting; using an operator name not in the grammar; smart quotes from copy-pasting from editors.","solutions":["Read the wrapped RecognitionException (the 'Caused by' chain) for line/char position and offending symbol.","Fix quoting: wrap string values in single quotes and escape embedded quotes.","Verify parentheses are balanced and operators are spelled exactly as the grammar expects (e.g. previous build state names, field operator names).","Use the condition builder/editor UI in OneDev instead of hand-writing the expression."],"exampleFix":"// before\ncondition: this succeeded || previous build failed\n\n// after (grammar-compliant syntax)\ncondition: this build is successful and previous build is failed","handlingStrategy":"try-catch","validationCode":"// no public pre-parse validator; dry-run parse yourself\ntry {\n    ActionCondition.parse(conditionText, job, build);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Malformed action condition\")) {\n        // reject/repair conditionText before real use\n    } else throw e;\n}","typeGuard":null,"tryCatchPattern":"try {\n    ActionCondition.parse(text, job, build);\n} catch (RuntimeException e) {\n    throw new IllegalArgumentException(\"Invalid condition '\" + text + \"': \" + e.getMessage(), e);\n}","preventionTips":["Validate condition strings with a dry parse in CI before shipping the buildspec.","Avoid hand-typing operators; copy from documented examples.","Beware smart quotes when pasting from rich-text editors."],"tags":["onedev","parser","buildspec","condition-syntax"],"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"}