theonedev/onedev · error · RuntimeException

Malformed log instruction

Error message

Malformed log instruction

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/buildspec/job/log/instruction/LogInstruction.java:42

	
	public abstract String getName();
	
	public abstract void execute(Map<String, List<String>> params);
	
	public static String getValue(TerminalNode valueNode) {
		return StringUtils.unescape(FenceAware.unfence(valueNode.getText()));
	}
	
	public static InstructionContext parse(String instructionString) {
		CharStream is = CharStreams.fromString(instructionString); 
		LogInstructionLexer lexer = new LogInstructionLexer(is);
		lexer.removeErrorListeners();
		lexer.addErrorListener(new BaseErrorListener() {

			@Override
			public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
					int charPositionInLine, String msg, RecognitionException e) {
				throw new RuntimeException("Malformed log instruction");
			}
			
		});
		CommonTokenStream tokens = new CommonTokenStream(lexer);
		LogInstructionParser parser = new LogInstructionParser(tokens);
		parser.removeErrorListeners();
		parser.setErrorHandler(new BailErrorStrategy());
		return parser.instruction();
	}
	
}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Re-check the log instruction string for typos, unmatched quotes, and parentheses.
  2. Compare against documented log instruction syntax examples.
  3. Use the UI log-setting editor to construct the instruction instead of typing it raw.

Example fix

// before
log instruction: since last error until timeout'

// after (balanced, grammar-valid)
log instruction: since last error until 'success'
Defensive patterns

Strategy: try-catch

Validate before calling

try {
    LogInstruction.parse(instructionText);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("Malformed log instruction")) {
        // reject instructionText before applying to job logs
    } else throw e;
}

Try / catch

try {
    LogInstruction.parse(text);
} catch (RuntimeException e) {
    throw new IllegalArgumentException("Invalid log instruction '" + text + "'", e);
}

Prevention

When it happens

Trigger: Passing a malformed log specifier/instruction (e.g. in error tracking or log settings) — unbalanced quotes/parens, unknown keywords, or invalid token sequences.

Common situations: Hand-editing log instructions in job configuration; copy-paste introducing smart quotes or stray characters; syntax drift after OneDev upgrades.

Understand the failure class

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/8a7e800630928da4. Report an issue: GitHub.