{"record":{"id":"8186ec7bb6173f6c","repo":"apache/cassandra","slug":"s-8186ec","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java","lineNumber":723,"sourceCode":"\n            return insert;\n        }\n    }\n\n    public static <T extends CQLStatement.Raw> T parseStatement(String query, Class<T> klass, String type)\n    {\n        try\n        {\n            CQLStatement.Raw stmt = CQLFragmentParser.parseAnyUnhandled(CqlParser::query, query);\n\n            if (!stmt.getClass().equals(klass))\n                throw new IllegalArgumentException(\"Invalid query, must be a \" + type + \" statement but was: \" + stmt.getClass());\n\n            return klass.cast(stmt);\n        }\n        catch (RecognitionException | RequestValidationException e)\n        {\n            throw new IllegalArgumentException(e.getMessage(), e);\n        }\n    }\n}\n","sourceCodeStart":705,"sourceCodeEnd":727,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java#L705-L727","documentation":"In the same parseStatement method, when the CQL string cannot be parsed at all (ANTLR RecognitionException) or fails semantic validation (RequestValidationException, e.g. unknown table/column, bad syntax), the method rethrows it as an IllegalArgumentException whose message is the underlying parser/validator message. The '%s' in the catalog is the dynamic parser message; it tells the developer exactly what part of the CQL was invalid.","triggerScenarios":"Passing a syntactically invalid CQL string (bad syntax, missing parentheses, wrong placeholders) or a semantically invalid one (unknown keyspace/table/column, invalid type usage) to StressCQLSSTableWriter.parseStatement, causing CQLFragmentParser.parseAnyUnhandled to throw RecognitionException or RequestValidationException.","commonSituations":"Typo in table or column names; forgetting to add the keyspace or using one that does not exist; CQL that is valid interactively but invalid here (e.g. empty string); copy-pasted CQL containing cqlsh-only directives.","solutions":["Read the wrapped message for the exact syntax or validation problem and fix the CQL string.","Validate the CQL in cqlsh or a CQL editor before embedding it in the stress tool.","Ensure the keyspace and table exist and are spelled correctly (case-sensitive quoted identifiers).","Catch IllegalArgumentException around writer construction and log e.getCause() (the original RequestValidationException) for full details."],"exampleFix":"// before\nString cql = \"INSERT INTO ks.t (k, v) VALUES (?, ?\"; // missing ')'\n// after\nString cql = \"INSERT INTO ks.t (k, v) VALUES (?, ?)\";","handlingStrategy":"validation","validationCode":"if (cql == null || cql.trim().isEmpty())\n    throw new IllegalArgumentException(\"CQL string must be non-empty\");\n// optionally pre-validate with a parser or cqlsh dry-run","typeGuard":null,"tryCatchPattern":"try {\n    writer = StressCQLSSTableWriter.builder(schema, cql).build();\n} catch (IllegalArgumentException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof RequestValidationException)\n        throw new IllegalStateException(\"Invalid CQL: \" + cause.getMessage(), cause);\n    throw e;\n}","preventionTips":["Validate CQL in cqlsh before embedding it in stress profiles.","Use fully-qualified keyspace.table names in stress CQL.","Keep placeholders (?) consistent with bind ordering in the writer loop.","Pin schema changes and re-check stress profiles after migrations."],"tags":["cql","parse-error","sstable-writer"],"backgroundTag":"schema-validation-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}