{"record":{"id":"d8f5e5ac6f2ee6bd","repo":"apache/cassandra","slug":"history-file-s-is-not-a-file-n","errorCode":null,"errorMessage":"History file %s is not a file.%n","messagePattern":"History file (.+?) is not a file\\.%n","errorType":"console","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/History.java","lineNumber":91,"sourceCode":"            commandLines = historyCommands.subList(size - commands, size);\n\n        return commandLines;\n    }\n\n    /**\n     * Nodetool is appending command to history file before it is executed so us checking on its\n     * existence and validating it is not technically necessary however nodetool is also swallowing\n     * all errors when it was not succesful in appending to the history file so better to check here in that case.\n     *\n     * @param historyFile file to check that it is actually a file which exists and it is readable\n     */\n    void validateHistoryFile(File historyFile)\n    {\n        if (!historyFile.exists())\n            throw new IllegalStateException(String.format(\"History file %s does not exist.%n\", historyFile.absolutePath()));\n\n        if (!historyFile.isFile())\n            throw new IllegalStateException(String.format(\"History file %s is not a file.%n\", historyFile.absolutePath()));\n\n        if (!historyFile.isReadable())\n            throw new IllegalStateException(String.format(\"History file %s is not readable.%n\", historyFile.absolutePath()));\n    }\n}\n","sourceCodeStart":73,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/History.java#L73-L97","documentation":"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.').","triggerScenarios":"A directory named nodetool.history exists at ~/.cassandra/nodetool.history (created by mistake by a script or `mkdir`); a symlink resolving to a directory.","commonSituations":"Provisioning scripts that `mkdir -p $HOME/.cassandra/nodetool.history` by accident; mount points creating directories at the expected path.","solutions":["Remove or rename the directory at the printed path so nodetool can recreate the file: `mv ~/.cassandra/nodetool.history ~/.cassandra/nodetool.history.d`","Fix the provisioning script that created a directory at that path","Recreate the history file with correct permissions"],"exampleFix":"// before\nmkdir -p ~/.cassandra/nodetool.history\n// after\nmkdir -p ~/.cassandra && touch ~/.cassandra/nodetool.history","handlingStrategy":"validation","validationCode":"# ensure the history path is a regular file, not a directory\nHIST=\"$HOME/.cassandra/nodetool.history\"\n[ -d \"$HIST\" ] && { echo \"$HIST is a directory; remove or rename it\"; exit 1; }","typeGuard":null,"tryCatchPattern":"try { runNodetool(\"history\"); } catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"is not a file\")) { log(\"Fix path: a directory occupies the history file location\"); return; }\n    throw e;\n}","preventionTips":["Never mkdir at the exact history file path in provisioning scripts","Verify with `file ~/.cassandra/nodetool.history` that it is a regular file"],"tags":["nodetool","history","filesystem","path"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}