{"record":{"id":"8a7e800630928da4","repo":"theonedev/onedev","slug":"malformed-log-instruction","errorCode":null,"errorMessage":"Malformed log instruction","messagePattern":"Malformed log instruction","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/job/log/instruction/LogInstruction.java","lineNumber":42,"sourceCode":"\t\n\tpublic abstract String getName();\n\t\n\tpublic abstract void execute(Map<String, List<String>> params);\n\t\n\tpublic static String getValue(TerminalNode valueNode) {\n\t\treturn StringUtils.unescape(FenceAware.unfence(valueNode.getText()));\n\t}\n\t\n\tpublic static InstructionContext parse(String instructionString) {\n\t\tCharStream is = CharStreams.fromString(instructionString); \n\t\tLogInstructionLexer lexer = new LogInstructionLexer(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 log instruction\");\n\t\t\t}\n\t\t\t\n\t\t});\n\t\tCommonTokenStream tokens = new CommonTokenStream(lexer);\n\t\tLogInstructionParser parser = new LogInstructionParser(tokens);\n\t\tparser.removeErrorListeners();\n\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\treturn parser.instruction();\n\t}\n\t\n}\n","sourceCodeStart":24,"sourceCodeEnd":54,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/job/log/instruction/LogInstruction.java#L24-L54","documentation":"Thrown by LogInstruction's ANTLR syntaxError listener when a log instruction string fails to parse against the log instruction grammar. Unlike some siblings it does not wrap the RecognitionException, so only the message is available; the instruction text itself is invalid.","triggerScenarios":"Passing a malformed log specifier/instruction (e.g. in error tracking or log settings) — unbalanced quotes/parens, unknown keywords, or invalid token sequences.","commonSituations":"Hand-editing log instructions in job configuration; copy-paste introducing smart quotes or stray characters; syntax drift after OneDev upgrades.","solutions":["Re-check the log instruction string for typos, unmatched quotes, and parentheses.","Compare against documented log instruction syntax examples.","Use the UI log-setting editor to construct the instruction instead of typing it raw."],"exampleFix":"// before\nlog instruction: since last error until timeout'\n\n// after (balanced, grammar-valid)\nlog instruction: since last error until 'success'","handlingStrategy":"try-catch","validationCode":"try {\n    LogInstruction.parse(instructionText);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Malformed log instruction\")) {\n        // reject instructionText before applying to job logs\n    } else throw e;\n}","typeGuard":null,"tryCatchPattern":"try {\n    LogInstruction.parse(text);\n} catch (RuntimeException e) {\n    throw new IllegalArgumentException(\"Invalid log instruction '\" + text + \"'\", e);\n}","preventionTips":["Copy log instruction syntax from official examples.","Check for stray characters from copy-paste.","Keep instruction strings simple; split complex logic across multiple instructions where supported."],"tags":["onedev","parser","log-instruction","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"}