{"record":{"id":"e28a0bb721622083","repo":"alibaba/canal","slug":"illeagal-operationtype","errorCode":null,"errorMessage":"illeagal operationType : {}","messagePattern":"illeagal operationType : (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/JsonDiffConversion.java","lineNumber":178,"sourceCode":"        }\n\n        return builder;\n    }\n\n    private static String json_diff_operation_name(int operationType, int last_path_char) {\n        switch (operationType) {\n            case DIFF_OPERATION_REPLACE:\n                return \"JSON_REPLACE\";\n            case DIFF_OPERATION_INSERT:\n                if (last_path_char == ']') {\n                    return \"JSON_ARRAY_INSERT\";\n                } else {\n                    return \"JSON_INSERT\";\n                }\n            case DIFF_OPERATION_REMOVE:\n                return \"JSON_REMOVE\";\n        }\n        throw new IllegalArgumentException(\"illeagal operationType : \" + operationType);\n    }\n}\n","sourceCodeStart":160,"sourceCodeEnd":181,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/JsonDiffConversion.java#L160-L181","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// This should be unreachable through normal API usage.\n// No specific catch pattern needed; if it fires, investigate the caller's validation.\ntry {\n    JsonDiffConversion.print_json_diff(buffer, len, columnName, columnIndex, charset);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"illeagal operationType\")) {\n        logger.error(\"Unreachable defensive guard fired in json_diff_operation_name — investigate caller logic\");\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["json-diff","binlog","defensive-code","unreachable"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}