{"record":{"id":"e2053d9c9ef9828c","repo":"apache/cassandra","slug":"unable-to-make-long-from-s","errorCode":null,"errorMessage":"Unable to make long from '%s'","messagePattern":"Unable to make long from '(.+?)'","errorType":"exception","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/LongType.java","lineNumber":111,"sourceCode":"        else\n            return accessor.valueOf(ByteSourceInverse.getVariableLengthInteger(comparableBytes));\n    }\n\n    public ByteBuffer fromString(String source) throws MarshalException\n    {\n        // Return an empty ByteBuffer for an empty string.\n        if (source.isEmpty())\n            return ByteBufferUtil.EMPTY_BYTE_BUFFER;\n\n        long longType;\n\n        try\n        {\n            longType = Long.parseLong(source);\n        }\n        catch (Exception e)\n        {\n            throw new MarshalException(String.format(\"Unable to make long from '%s'\", source), e);\n        }\n\n        return decompose(longType);\n    }\n\n    @Override\n    public Term fromJSONObject(Object parsed) throws MarshalException\n    {\n        try\n        {\n            if (parsed instanceof String)\n                return new Constants.Value(fromString((String) parsed));\n\n            Number parsedNumber = (Number) parsed;\n            if (!(parsedNumber instanceof Integer || parsedNumber instanceof Long))\n                throw new MarshalException(String.format(\"Expected a bigint value, but got a %s: %s\", parsed.getClass().getSimpleName(), parsed));\n\n            return new Constants.Value(getSerializer().serialize(parsedNumber.longValue()));","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/LongType.java#L93-L129","documentation":"LongType.fromString parses a string as a signed 64-bit long (Long.parseLong). Any non-numeric string or a value outside Long.MIN_VALUE..Long.MAX_VALUE causes parseLong to throw, which is wrapped in a MarshalException with this message.","triggerScenarios":"Inserting/updating a bigint column with a string literal that is not a valid long: text, empty string, decimal like '1.5', or a number exceeding 64-bit range (e.g. values larger than 9223372036854775807).","commonSituations":"Users inserting values meant for a varint/decimal column into a bigint column; JavaScript numbers losing precision or arriving as strings; locale-formatted numbers with thousand separators.","solutions":["Supply a valid integer literal within the 64-bit range, e.g. '123' not '1.5'.","If the value exceeds long range, change the column type to varint or decimal.","Strip formatting (commas, spaces) and parse/validate in the client before sending."],"exampleFix":"// before\nINSERT INTO t (n) VALUES ('1,000,000');\n// after\nINSERT INTO t (n) VALUES ('1000000');","handlingStrategy":"try-catch","validationCode":"try { Long.parseLong(source.trim()); } catch (NumberFormatException e) { throw new IllegalArgumentException(\"Not a 64-bit integer: \" + source); }","typeGuard":"boolean isValidLong(String s) { try { Long.parseLong(s.trim()); return true; } catch (Exception e) { return false; } }","tryCatchPattern":"try { term = LongType.instance.fromString(source); } catch (MarshalException e) { throw new BadRequestException(\"bigint column requires a 64-bit integer: \" + source); }","preventionTips":["Validate numeric strings with Long.parseLong client-side before binding.","Use varint/decimal columns for values that may exceed 64-bit range.","Strip locale formatting (commas, spaces, signs) before parsing."],"tags":["bigint","parsing","marshal","number-format"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}