alibaba/canal · warning · IllegalArgumentException
illeagal operationType : {}
Error message
illeagal operationType : {} What it means
Thrown by json_diff_operation_name() when operationType does not match DIFF_OPERATION_REPLACE (0), DIFF_OPERATION_INSERT (1), or DIFF_OPERATION_REMOVE (2). This is a defensive guard that should be unreachable in normal operation because the caller (print_json_diff) already validates operation_int < JSON_DIFF_OPERATION_COUNT before calling this function. If reached, it indicates a logic bypass or direct invocation with an invalid value.
Source
Thrown at dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/JsonDiffConversion.java:178
}
return builder;
}
private static String json_diff_operation_name(int operationType, int last_path_char) {
switch (operationType) {
case DIFF_OPERATION_REPLACE:
return "JSON_REPLACE";
case DIFF_OPERATION_INSERT:
if (last_path_char == ']') {
return "JSON_ARRAY_INSERT";
} else {
return "JSON_INSERT";
}
case DIFF_OPERATION_REMOVE:
return "JSON_REMOVE";
}
throw new IllegalArgumentException("illeagal operationType : " + operationType);
}
}
View on GitHub (pinned to 87be50e876)
Solutions
- Verify no code path in JsonDiffConversion calls json_diff_operation_name without first checking operation_int < JSON_DIFF_OPERATION_COUNT.
- Since the function is private and the only caller validates beforehand, this is likely a non-issue — treat as a programming error if it surfaces.
- Consider adding a unit test that calls json_diff_operation_name with values 0, 1, 2 to confirm coverage.
Defensive patterns
Strategy: try-catch
Try / catch
// This should be unreachable through normal API usage.
// No specific catch pattern needed; if it fires, investigate the caller's validation.
try {
JsonDiffConversion.print_json_diff(buffer, len, columnName, columnIndex, charset);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("illeagal operationType")) {
logger.error("Unreachable defensive guard fired in json_diff_operation_name — investigate caller logic");
}
throw e;
} Prevention
- This is a defensive guard that should never fire through normal API usage.
- Do not call the private json_diff_operation_name method directly via reflection.
- If it fires, check whether the operation_int >= JSON_DIFF_OPERATION_COUNT guard in print_json_diff was bypassed.
When it happens
Trigger: Direct call to json_diff_operation_name() with an operationType outside [0,2], or a code path that bypasses the operation_int >= JSON_DIFF_OPERATION_COUNT guard in print_json_diff. The function is private static, so only reachable from within JsonDiffConversion.
Common situations: This is essentially unreachable through normal API usage. It would indicate a regression in the caller's validation logic, a reflection-based test calling the private method directly, or JVM JIT reordering causing the guard to be skipped (extremely unlikely).
Related errors
- reading operation type (invalid operation code)
- skipping path
- reading json diff
- parsing json value
- Invalid charset id: {}
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/e28a0bb721622083.
Report an issue: GitHub.