{"record":{"id":"c91226cb3b86f4b8","repo":"apache/seatunnel","slug":"source-offset-key-parameter-value-ob","errorCode":null,"errorMessage":"Source offset '\" + key + \"' parameter value \" + obj + \" could not be converted to a long","messagePattern":"Source offset '\" \\+ key \\+ \"' parameter value \" \\+ obj \\+ \" could not be converted to a long","errorType":"exception","errorClass":"ConnectException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/offset/Offset.java","lineNumber":53,"sourceCode":" */\npublic abstract class Offset implements Comparable<Offset>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    @Getter protected Map<String, String> offset;\n\n    protected long longOffsetValue(Map<String, ?> values, String key) {\n        Object obj = values.get(key);\n        if (obj == null) {\n            return 0L;\n        }\n        if (obj instanceof Number) {\n            return ((Number) obj).longValue();\n        }\n        try {\n            return Long.parseLong(obj.toString());\n        } catch (NumberFormatException e) {\n            throw new ConnectException(\n                    \"Source offset '\"\n                            + key\n                            + \"' parameter value \"\n                            + obj\n                            + \" could not be converted to a long\");\n        }\n    }\n\n    public boolean isAtOrBefore(Offset that) {\n        return this.compareTo(that) <= 0;\n    }\n\n    public boolean isBefore(Offset that) {\n        return this.compareTo(that) < 0;\n    }\n\n    public boolean isAtOrAfter(Offset that) {\n        return this.compareTo(that) >= 0;","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/offset/Offset.java#L35-L71","documentation":"Offset.longOffsetValue() converts an offset map entry to a long (e.g. binlog filename position or LSN). If the stored value is neither a Number nor a parseable long string, it throws ConnectException. This guards against corrupted or foreign-format offset data in checkpoint state or startup-offset configuration.","triggerScenarios":"longOffsetValue(key) called with a map value like \"mysql-bin.000004\" (a non-numeric filename supplied where a numeric position was expected), null-adjacent garbage, or an offset restored from an incompatible checkpoint format.","commonSituations":"Users configuring startup.offset with the binlog FILE NAME in the position field instead of a number; checkpoint state written by a different connector version; hand-edited offset JSON with wrong types.","solutions":["Check the offset map value for the given key; supply a numeric string (e.g. \"position\": \"12345\", not the filename)","Fix the startup offset config: the binlog filename goes in its own key; only the position is a long","If restored from a bad checkpoint, delete/redo the savepoint with a correctly formatted offset","Clear stale checkpoint state and restart the job from the corrected offset"],"exampleFix":"// before\n// { \"filename\": \"mysql-bin.000004\", \"position\": \"mysql-bin.000004\" }\n// after\n// { \"filename\": \"mysql-bin.000004\", \"position\": \"123456\" }","handlingStrategy":"validation","validationCode":"// Validate offset fields are numeric before starting from a specific offset:\nString pos = offsetMap.get(\"position\");\nif (pos == null || !pos.matches(\"\\\\d+\")) throw new IllegalArgumentException(\"position must be a long, got: \" + pos);","typeGuard":"Long safeLong(Object v) { if (v instanceof Number) return ((Number) v).longValue(); try { return Long.parseLong(String.valueOf(v)); } catch (NumberFormatException e) { return null; } }","tryCatchPattern":"try { long p = offset.longOffsetValue(\"position\"); }\ncatch (ConnectException e) { LOG.error(\"Bad offset value for {}: fix startup.offset config\", e.getMessage()); throw e; }","preventionTips":["Never put the binlog filename into the position field","Validate startup.offset JSON types before job submission","Don't hand-edit checkpoint offset state"],"tags":["cdc","offset","parsing","configuration"],"backgroundTag":"invalid-argument-format","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}