{"record":{"id":"49e634ceb22b25a1","repo":"apache/cassandra","slug":"none-of-the-arguments-may-be-null","errorCode":null,"errorMessage":"none of the arguments may be null","messagePattern":"none of the arguments may be null","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/FormatFcts.java","lineNumber":81,"sourceCode":"     * <p>\n     * Supported column types on which this function is possible to be applied:\n     * <pre>DOUBLE</pre>\n     */\n    public static String format(double value)\n    {\n        return decimalFormat.format(value);\n    }\n\n    public static void addFunctionsTo(NativeFunctions functions)\n    {\n        functions.add(FormatBytesFct.factory());\n        functions.add(FormatTimeFct.factory());\n    }\n\n    private static long validateAndGetValue(Arguments arguments)\n    {\n        if (arguments.containsNulls())\n            throw new InvalidRequestException(\"none of the arguments may be null\");\n\n        long value = getValue(arguments);\n\n        if (value < 0)\n            throw new InvalidRequestException(\"value must be non-negative\");\n\n        return value;\n    }\n\n    private static long getValue(Arguments arguments)\n    {\n        Optional<String> maybeString = getAsString(arguments, 0);\n\n        if (maybeString.isPresent())\n        {\n            try\n            {\n                return Long.parseLong(maybeString.get());","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/FormatFcts.java#L63-L99","documentation":"Thrown by FormatFcts.validateAndGetValue when any argument to a time-formatting function is null. These functions do not accept NULL inputs, and a null argument is rejected with InvalidRequestException before formatting is attempted.","triggerScenarios":"Calling a format function with a NULL literal or a NULL-valued column/tuple element as an argument.","commonSituations":"Formatting nullable timestamp columns where rows contain nulls; SELECT with format over data with missing values; computed arguments that produce null on failure.","solutions":["Use coalesce()/null-handling to substitute a default before calling the format function.","Filter out rows with null arguments (WHERE col IS NOT NULL) in the query.","Return a sentinel/empty string from the application for null timestamps instead of null."],"exampleFix":"// before: SELECT formatDate(created_at) ... -- created_at may be NULL\n// after\nSELECT formatDate(coalesce(created_at, toTimestamp(now()))) ...","handlingStrategy":"validation","validationCode":"// CQL: guard nulls at query time\nSELECT CASE WHEN ts IS NULL THEN NULL ELSE formatDate(ts) END FROM t; -- or coalesce(ts, defaultTs)","typeGuard":null,"tryCatchPattern":"catch (InvalidRequestException e) { if (e.getMessage().contains(\"none of the arguments may be null\")) { log.warn(\"null argument to format function\"); } }","preventionTips":["Treat format functions as non-null-strict; wrap nullable inputs with coalesce.","Filter IS NOT NULL when formatting many rows.","Decide and document a default for missing timestamps."],"tags":["cassandra","cql","function","null-argument"],"backgroundTag":"null-argument","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"}