apache/cassandra · error · InvalidRequestException

none of the arguments may be null

Error message

none of the arguments may be null

What it means

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.

Source

Thrown at src/java/org/apache/cassandra/cql3/functions/FormatFcts.java:81

     * <p>
     * Supported column types on which this function is possible to be applied:
     * <pre>DOUBLE</pre>
     */
    public static String format(double value)
    {
        return decimalFormat.format(value);
    }

    public static void addFunctionsTo(NativeFunctions functions)
    {
        functions.add(FormatBytesFct.factory());
        functions.add(FormatTimeFct.factory());
    }

    private static long validateAndGetValue(Arguments arguments)
    {
        if (arguments.containsNulls())
            throw new InvalidRequestException("none of the arguments may be null");

        long value = getValue(arguments);

        if (value < 0)
            throw new InvalidRequestException("value must be non-negative");

        return value;
    }

    private static long getValue(Arguments arguments)
    {
        Optional<String> maybeString = getAsString(arguments, 0);

        if (maybeString.isPresent())
        {
            try
            {
                return Long.parseLong(maybeString.get());

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Use coalesce()/null-handling to substitute a default before calling the format function.
  2. Filter out rows with null arguments (WHERE col IS NOT NULL) in the query.
  3. Return a sentinel/empty string from the application for null timestamps instead of null.

Example fix

// before: SELECT formatDate(created_at) ... -- created_at may be NULL
// after
SELECT formatDate(coalesce(created_at, toTimestamp(now()))) ...
Defensive patterns

Strategy: validation

Validate before calling

// CQL: guard nulls at query time
SELECT CASE WHEN ts IS NULL THEN NULL ELSE formatDate(ts) END FROM t; -- or coalesce(ts, defaultTs)

Try / catch

catch (InvalidRequestException e) { if (e.getMessage().contains("none of the arguments may be null")) { log.warn("null argument to format function"); } }

Prevention

When it happens

Trigger: Calling a format function with a NULL literal or a NULL-valued column/tuple element as an argument.

Common situations: Formatting nullable timestamp columns where rows contain nulls; SELECT with format over data with missing values; computed arguments that produce null on failure.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/49e634ceb22b25a1. Report an issue: GitHub.