{"record":{"id":"2ab0a6d64016b52b","repo":"apache/cassandra","slug":"there-was-a-problem-parsing-the-keyspace-cql-s","errorCode":null,"errorMessage":"There was a problem parsing the keyspace cql: %s","messagePattern":"There was a problem parsing the keyspace cql: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/StressProfile.java","lineNumber":217,"sourceCode":"\n        assert keyspaceName != null : \"keyspace name is required in yaml file\";\n        assert tableName != null : \"table name is required in yaml file\";\n        assert queries != null : \"queries map is required in yaml file\";\n\n        for (String query : queries.keySet())\n            assert !tokenRangeQueries.containsKey(query) :\n                String.format(\"Found %s in both queries and token_range_queries, please use different names\", query);\n\n        if (keyspaceCql != null && keyspaceCql.length() > 0)\n        {\n            try\n            {\n                String name = CQLFragmentParser.parseAnyUnhandled(CqlParser::createKeyspaceStatement, keyspaceCql).keyspaceName;\n                assert name.equalsIgnoreCase(keyspaceName) : \"Name in keyspace_definition doesn't match keyspace property: '\" + name + \"' != '\" + keyspaceName + \"'\";\n            }\n            catch (RecognitionException | SyntaxException e)\n            {\n                throw new IllegalArgumentException(\"There was a problem parsing the keyspace cql: \" + e.getMessage());\n            }\n        }\n        else\n        {\n            keyspaceCql = null;\n        }\n\n        if (tableCql != null && tableCql.length() > 0)\n        {\n            try\n            {\n                String name = CQLFragmentParser.parseAnyUnhandled(CqlParser::createTableStatement, tableCql).table();\n                assert name.equalsIgnoreCase(tableName) : \"Name in table_definition doesn't match table property: '\" + name + \"' != '\" + tableName + \"'\";\n            }\n            catch (RecognitionException | RuntimeException e)\n            {\n                throw new IllegalArgumentException(\"There was a problem parsing the table cql: \" + e.getMessage());\n            }","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/StressProfile.java#L199-L235","documentation":"StressProfile.init validates the optional keyspace_definition CQL by parsing it with CqlParser::createKeyspaceStatement; a RecognitionException or SyntaxException is converted to IllegalArgumentException \"There was a problem parsing the keyspace cql: <message>\". This means the keyspace CQL in the stress profile is syntactically invalid or is not a CREATE KEYSPACE statement. A related assert also fails if the parsed keyspace name does not match the profile's keyspace property.","triggerScenarios":"Providing a keyspace_definition in the stress profile whose CQL has syntax errors, uses grammar unsupported by the bundled parser version, or declares a different keyspace name than the profile's keyspace property (assertion path).","commonSituations":"Copy-pasted keyspace DDL with trailing statements or stray semicolons; using CQL features newer than the bundled ANTLR parser; mismatch between 'keyspace:' and the name in keyspace_definition; YAML indentation mangling the multi-line CQL string.","solutions":["Read the embedded parse message to locate the syntax error and fix the CQL in keyspace_definition.","Ensure the definition contains exactly one CREATE KEYSPACE statement whose name equals the profile's keyspace property.","Check YAML block-scalar indentation so the whole CQL reaches the parser as one string.","Test the CQL against the target Cassandra version's cqlsh to confirm it parses there."],"exampleFix":"// before (profile YAML)\nkeyspace_definition: |\n  CREATE KEYSPCE ks WITH replication = {'class': 'SimpleStrategy'};\n// after\nkeyspace_definition: |\n  CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};","handlingStrategy":"validation","validationCode":"String cql = profile.keyspaceDefinition; if (cql == null || !cql.trim().toUpperCase().startsWith(\"CREATE KEYSPACE\")) throw new IllegalArgumentException(\"keyspace_definition must be a single CREATE KEYSPACE statement matching keyspace: \" + profile.keyspace);","typeGuard":null,"tryCatchPattern":"try { profile.init(stressSettings); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"There was a problem parsing the keyspace cql\")) System.err.println(\"Fix keyspace_definition in your stress profile YAML: \" + e.getMessage()); throw e; }","preventionTips":["Test keyspace DDL in cqlsh before embedding it in the stress profile.","Keep the keyspace name identical in 'keyspace:' and keyspace_definition.","Validate YAML block-scalar indentation for multi-line CQL."],"tags":["cql","parsing","stress-profile"],"backgroundTag":"invalid-argument-format","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"}