{"record":{"id":"b71eacfd8339857f","repo":"shadow1ng/fscan","slug":"cassandra-query-failed-s","errorCode":null,"errorMessage":"cassandra query failed: %s","messagePattern":"cassandra query failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/cassandra.go","lineNumber":217,"sourceCode":"\t}\n\topcode := header[4]\n\tbodyLen := int(binary.BigEndian.Uint32(header[5:9]))\n\tif bodyLen == 0 {\n\t\treturn opcode, []byte{}, nil\n\t}\n\tif bodyLen > maxCQLFrameBody {\n\t\treturn opcode, nil, fmt.Errorf(\"cassandra frame too large: %d\", bodyLen)\n\t}\n\tbody := make([]byte, bodyLen)\n\tif _, err := io.ReadFull(conn, body); err != nil {\n\t\treturn opcode, nil, err\n\t}\n\treturn opcode, body, nil\n}\n\nfunc validateCQLQueryResponse(opcode byte, body []byte) error {\n\tif opcode == cqlOpError {\n\t\treturn fmt.Errorf(\"cassandra query failed: %s\", string(body))\n\t}\n\tif opcode != cqlOpResult {\n\t\treturn fmt.Errorf(\"unexpected query opcode: %d\", opcode)\n\t}\n\treturn nil\n}\n\n// cqlStringMap CQL string map 编码: [2B count] [pairs: [2B len] [str]]\nfunc cqlStringMap(m map[string]string) []byte {\n\tvar buf []byte\n\tbuf = append(buf, 0x00, byte(len(m))) // count as short\n\tfor k, v := range m {\n\t\tbuf = append(buf, cqlShortString(k)...)\n\t\tbuf = append(buf, cqlShortString(v)...)\n\t}\n\treturn buf\n}\n","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/cassandra.go#L199-L235","documentation":"validateCQLQueryResponse checks the reply to the test query (SELECT cluster_name FROM system.local); if the server answered with an ERROR opcode, the raw server error is surfaced as 'cassandra query failed: %s'. Auth succeeded but the query itself failed.","triggerScenarios":"doCassandraAuth or tryNoAuthConnection completes authentication, sends the test query via cqlSend, reads the response with cqlRecv, and passes it to validateCQLQueryResponse which sees opcode == cqlOpError.","commonSituations":"Authenticated user lacks SELECT permission on system.local; keyspace/system table unavailable; query syntax rejected due to protocol-version quirks; node unhealthy during validation.","solutions":["Inspect the embedded server message to learn why the query failed (permissions, unavailable, syntax).","Grant the test user SELECT on system.local, or test with a higher-privileged account.","Retry against another node if the error indicates the node is unavailable or overloaded."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := validateCQLQueryResponse(opcode, body); err != nil {\n    var srv string\n    fmt.Sscanf(err.Error(), \"cassandra query failed: %s\", &srv)\n    log.Printf(\"test query rejected: %s\", srv)\n}","preventionTips":["Ensure the test account has SELECT permission on system.local.","Use a simple, version-stable validation query.","Check node health (nodetool status) if query failures cluster on one node."],"tags":["cassandra","cql","query","validation"],"backgroundTag":"database-query-failed","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}