apache/cassandra · error · IllegalStateException

History file is not a file.%n

Error message

History file %s is not a file.%n

What it means

History.validateHistoryFile requires the history path to be a regular file. If the path exists but is a directory (or a special file), it throws IllegalStateException('History file <path> is not a file.').

Solutions

  1. Remove or rename the directory at the printed path so nodetool can recreate the file: `mv ~/.cassandra/nodetool.history ~/.cassandra/nodetool.history.d`
  2. Fix the provisioning script that created a directory at that path
  3. Recreate the history file with correct permissions

Example fix

// before
mkdir -p ~/.cassandra/nodetool.history
// after
mkdir -p ~/.cassandra && touch ~/.cassandra/nodetool.history
Defensive patterns

Strategy: validation

Validate before calling

# ensure the history path is a regular file, not a directory
HIST="$HOME/.cassandra/nodetool.history"
[ -d "$HIST" ] && { echo "$HIST is a directory; remove or rename it"; exit 1; }

Try / catch

try { runNodetool("history"); } catch (IllegalStateException e) {
    if (e.getMessage().contains("is not a file")) { log("Fix path: a directory occupies the history file location"); return; }
    throw e;
}

Prevention

When it happens

Trigger: A directory named nodetool.history exists at ~/.cassandra/nodetool.history (created by mistake by a script or `mkdir`); a symlink resolving to a directory.

Common situations: Provisioning scripts that `mkdir -p $HOME/.cassandra/nodetool.history` by accident; mount points creating directories at the expected path.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/tools/nodetool/History.java:91

            commandLines = historyCommands.subList(size - commands, size);

        return commandLines;
    }

    /**
     * Nodetool is appending command to history file before it is executed so us checking on its
     * existence and validating it is not technically necessary however nodetool is also swallowing
     * all errors when it was not succesful in appending to the history file so better to check here in that case.
     *
     * @param historyFile file to check that it is actually a file which exists and it is readable
     */
    void validateHistoryFile(File historyFile)
    {
        if (!historyFile.exists())
            throw new IllegalStateException(String.format("History file %s does not exist.%n", historyFile.absolutePath()));

        if (!historyFile.isFile())
            throw new IllegalStateException(String.format("History file %s is not a file.%n", historyFile.absolutePath()));

        if (!historyFile.isReadable())
            throw new IllegalStateException(String.format("History file %s is not readable.%n", historyFile.absolutePath()));
    }
}

View on GitHub (pinned to 88fd0f6a0e)