{"record":{"id":"91b664866d0236b5","repo":"apache/cassandra","slug":"for-field-name-s-s","errorCode":null,"errorMessage":"For field name %s: %s","messagePattern":"For field name (.+?): (.+?)","errorType":"validation","errorClass":"SyntaxException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/FieldIdentifier.java","lineNumber":74,"sourceCode":"    /**\n     * Creates a {@code FieldIdentifier} from an internal string.\n     */\n    public static FieldIdentifier forInternalString(String text)\n    {\n        // If we store a field internally, we consider it as quoted, i.e. we preserve\n        // whatever case the text has.\n        return forQuoted(text);\n    }\n\n    private static ByteBuffer convert(String text)\n    {\n        try\n        {\n            return UTF8Type.instance.decompose(text);\n        }\n        catch (MarshalException e)\n        {\n            throw new SyntaxException(String.format(\"For field name %s: %s\", text, e.getMessage()));\n        }\n    }\n\n    @Override\n    public String toString()\n    {\n        return UTF8Type.instance.compose(bytes);\n    }\n\n    @Override\n    public final int hashCode()\n    {\n        return bytes.hashCode();\n    }\n\n    @Override\n    public final boolean equals(Object o)\n    {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/FieldIdentifier.java#L56-L92","documentation":"FieldIdentifier.convert wraps UTF8Type.decompose failures in this SyntaxException when turning a CQL field identifier (quoted or unquoted) into its UTF-8 byte representation. It fires when the text is not valid UTF-8, which for typical Java strings is rare but possible with malformed input from external sources.","triggerScenarios":"Calling FieldIdentifier.forUnquoted or forQuoted with text that fails UTF-8 validation (e.g. surrogates or invalid code points from raw bytes decoded permissively elsewhere).","commonSituations":"Reading user-supplied identifiers from raw network input or files decoded with a lossy/lenient charset; constructing identifiers from byte arrays with invalid sequences.","solutions":["Validate that identifier text is valid UTF-8 before creating the FieldIdentifier","Sanitize or reject identifiers containing unpaired surrogates or control characters","Decode external input strictly with StandardCharsets.UTF_8 and handle decoding errors at the boundary","Use ASCII-safe identifiers unless quoting is required"],"exampleFix":"// before\nFieldIdentifier.forQuoted(new String(rawBytes)); // rawBytes invalid UTF-8\n// after\nString text = new String(rawBytes, StandardCharsets.UTF_8);\nif (Charset.isSupported(\"UTF-8\") && isValidUtf8(rawBytes)) FieldIdentifier.forQuoted(text);","handlingStrategy":"validation","validationCode":"boolean isValidUtf8Text(String text) {\n    if (text == null) return false;\n    for (int i = 0; i < text.length(); i++) {\n        char c = text.charAt(i);\n        if (Character.isSurrogate(c) && !(Character.isHighSurrogate(c) && i + 1 < text.length() && Character.isLowSurrogate(text.charAt(i + 1)))) return false;\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try { FieldIdentifier.forQuoted(text); } catch (SyntaxException e) { throw new IllegalArgumentException(\"Invalid identifier: \" + text, e); }","preventionTips":["Decode all external input with StandardCharsets.UTF_8 strictly","Reject unpaired surrogates at input boundaries","Prefer ASCII identifiers unless quoting is required","Validate identifiers early, before query construction"],"tags":["cql","identifier","utf-8"],"backgroundTag":"invalid-identifier-format","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"}