{"record":{"id":"ec9361ef1298fa56","repo":"apache/cassandra","slug":"the-results-path-basepath-should-be-an-existi","errorCode":null,"errorMessage":"The results path (${basePath}) should be an existing directory","messagePattern":"The results path \\((.+?)\\) should be an existing directory","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/fqltool/src/org/apache/cassandra/fqltool/commands/Replay.java","lineNumber":85,"sourceCode":"    @Option(paramLabel = \"store_queries\", names = { \"--store-queries\" }, description = \"Path to store the queries executed. Stores queries in the same order as the result sets are in the result files. Requires --results\")\n    private String queryStorePath;\n\n    @Option(paramLabel = \"replay_ddl_statements\", names = { \"--replay-ddl-statements\" }, description = \"If specified, replays DDL statements as well, they are excluded from replaying by default.\")\n    private boolean replayDDLStatements;\n\n    @Override\n    public void run()\n    {\n        try\n        {\n            List<File> resultPaths = null;\n            if (resultPath != null)\n            {\n                File basePath = new File(resultPath);\n                if (!basePath.exists() || !basePath.isDirectory())\n                {\n                    System.err.println(\"The results path (\" + basePath + \") should be an existing directory\");\n                    throw new IllegalArgumentException(\"The results path (\" + basePath + \") should be an existing directory\");\n                }\n                resultPaths = targetHosts.stream().map(target -> new File(basePath, target)).collect(Collectors.toList());\n                resultPaths.forEach(File::mkdir);\n            }\n            if (targetHosts.size() < 1)\n            {\n                throw new IllegalArgumentException(\"You need to state at least one --target host to replay the query against\");\n            }\n            replay(keyspace, arguments, targetHosts, resultPaths, queryStorePath, replayDDLStatements);\n        }\n        catch (Exception e)\n        {\n            throw new RuntimeException(e);\n        }\n    }\n\n    public static void replay(String keyspace, List<String> arguments, List<String> targetHosts, List<File> resultPaths, String queryStorePath, boolean replayDDLStatements)\n    {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/fqltool/src/org/apache/cassandra/fqltool/commands/Replay.java#L67-L103","documentation":"Replay.run validates that the --results path, when provided, already exists and is a directory; it does not create it. If the path is missing or a regular file, it prints the message to stderr and throws IllegalArgumentException. Per-target subdirectories are then created inside it for comparison results.","triggerScenarios":"Running fqltool replay with --results pointing to a non-existent path or an existing file rather than a directory.","commonSituations":"Typos in the results path; assuming the tool creates the directory; pointing at a results file from a previous run.","solutions":["Create the directory beforehand: mkdir -p /path/to/results","Point --results at an existing directory, not a file","Fix typos in the --results argument"],"exampleFix":"// before\nfqltool replay ... --results /tmp/nonexistent\n// after\nmkdir -p /tmp/results\nfqltool replay ... --results /tmp/results","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction validateResultsPath(p) {\n  const st = fs.statSync(p);\n  if (!st.isDirectory()) throw new Error('--results must be an existing directory: ' + p);\n}","typeGuard":"const isExistingDirectory = p => { try { return require('fs').statSync(p).isDirectory(); } catch { return false; } };","tryCatchPattern":"try { runReplay(args); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"should be an existing directory\")) { exitWith(\"create the directory first: mkdir -p \" + args.results); } else throw e; }","preventionTips":["mkdir -p the results directory before running replay","Do not reuse a file path as --results","Validate all CLI paths in wrapper scripts"],"tags":["cli","filesystem","validation"],"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"}