{"record":{"id":"14695bff374bc6f3","repo":"apache/cassandra","slug":"invalid-value-for-property-s-it-should-be-a-st","errorCode":null,"errorMessage":"Invalid value for property '%s'. It should be a string","messagePattern":"Invalid value for property '(.+?)'\\. It should be a string","errorType":"validation","errorClass":"SyntaxException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/PropertyDefinitions.java","lineNumber":88,"sourceCode":"    }\n\n    public void removeProperty(String name)\n    {\n        properties.remove(name);\n    }\n\n    public boolean hasProperty(String name)\n    {\n        return properties.containsKey(name);\n    }\n\n    public String getString(String name) throws SyntaxException\n    {\n        Object val = properties.get(name);\n        if (val == null)\n            return null;\n        if (!(val instanceof String))\n            throw new SyntaxException(format(\"Invalid value for property '%s'. It should be a string\", name));\n        return (String)val;\n    }\n\n    @Nullable\n    public Set<QualifiedName> getQualifiedNames(String name) throws SyntaxException\n    {\n        Object val = properties.get(name);\n        if (val == null)\n            return null;\n        if (val instanceof Map && ((Map<?, ?>)val).isEmpty()) // to solve the ambiguity between empty map and empty set\n            return Collections.emptySet();\n        if (!(val instanceof Set))\n            throw new SyntaxException(String.format(\"Invalid value for property '%s'. It should be a set of identifiers.\", name));\n        return (Set<QualifiedName>) val;\n    }\n\n    @Nullable\n    protected Map<String, String> getMap(String name) throws SyntaxException","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/PropertyDefinitions.java#L70-L106","documentation":"PropertyDefinitions.getString() retrieves a WITH-clause property expected to be a plain string. If the property exists but its parsed value is not a String (e.g. a number, map, or set literal), a SyntaxException is thrown telling the caller the value must be a string.","triggerScenarios":"A property retrieved via getString (e.g. string-valued table/role options) was supplied as a numeric, boolean, or collection literal in the WITH clause.","commonSituations":"Quoting mistakes: forgetting quotes around an option value; query builders passing typed values where strings are required; copy-paste from options expecting maps.","solutions":["Quote the value so the parser produces a string: option = 'value'.","Inspect the statement's WITH clause and change the value's literal type to a string.","If using a query builder, pass a String-typed value for string properties."],"exampleFix":"-- before\nCREATE ROLE r WITH option = 123; -- numeric where string expected\n-- after\nCREATE ROLE r WITH option = '123';","handlingStrategy":"type-guard","validationCode":"Object v = options.get(name); if (v != null && !(v instanceof String)) throw new IllegalArgumentException(name + \" must be a string\");","typeGuard":"boolean isStringOption(Object v) { return v == null || v instanceof String; }","tryCatchPattern":"try { session.execute(ddl); } catch (SyntaxException e) { if (e.getMessage().contains(\"should be a string\")) { /* quote the value */ } else throw e; }","preventionTips":["Quote string option values in CQL","Type option values correctly in query builders","Test generated DDL against a parser"],"tags":["cql","syntax","type-mismatch"],"backgroundTag":"config-type-mismatch","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"}