{"record":{"id":"a5d514a12c368cd7","repo":"apache/shardingsphere","slug":"can-not-support-type-s","errorCode":null,"errorMessage":"Can not support type `%s`.","messagePattern":"Can not support type `(.+?)`\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/PrometheusMetricsCollectorFactory.java","lineNumber":48,"sourceCode":" * Metrics collector factory of Prometheus.\n */\npublic final class PrometheusMetricsCollectorFactory implements MetricsCollectorFactory {\n    \n    @Override\n    public MetricsCollector create(final MetricConfiguration metricConfig) {\n        switch (metricConfig.getType()) {\n            case COUNTER:\n                return new PrometheusMetricsCounterCollector(metricConfig);\n            case GAUGE:\n                return new PrometheusMetricsGaugeCollector(metricConfig);\n            case HISTOGRAM:\n                return new PrometheusMetricsHistogramCollector(metricConfig);\n            case SUMMARY:\n                return new PrometheusMetricsSummaryCollector(metricConfig);\n            case GAUGE_METRIC_FAMILY:\n                return new PrometheusMetricsGaugeMetricFamilyCollector(metricConfig);\n            default:\n                throw new UnsupportedOperationException(String.format(\"Can not support type `%s`.\", metricConfig.getType()));\n        }\n    }\n    \n    @Override\n    public String getType() {\n        return \"Prometheus\";\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":57,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/PrometheusMetricsCollectorFactory.java#L30-L57","documentation":"MySQL error 1043 (ER_BAD_HANDSHAKE) thrown by the proxy's MySQL authentication engine when the handshake response packet (MySQLHandshakeResponse41Packet) cannot be parsed — specifically when parsing runs past the end of the payload (IndexOutOfBoundsException). It means the client sent a malformed or truncated handshake response, so the proxy cannot recover username, auth response, or database and closes the negotiation with HandshakeException.","triggerScenarios":"Connecting with a client that sends a handshake response shorter or differently laid out than Handshake Response 41 expects: truncated TCP payload, non-MySQL protocol bytes sent to port 3307, a very old client (pre-4.1 protocol) that sends Handshake Response 320, or a TLS-capable client that missequences its SSL negotiation.","commonSituations":"Pointing a PostgreSQL/other protocol client or a health-check TCP probe at the MySQL proxy port; old MySQL client libraries; middleware/LB (e.g. HAProxy in tcp mode with a bogus probe) writing bytes into the stream; clients with a bad ssl-mode setting; version mismatch between client protocol and proxy expectations.","solutions":["Verify the client actually speaks MySQL protocol and connects to the MySQL frontend port of the proxy, not another dialect's port.","Upgrade the MySQL client/driver to a version that sends a standard Handshake Response 41 packet.","Check the proxy WARN log — it prints a hex dump of the received handshake — and compare it against the expected Handshake Response 41 layout to find the truncation point.","If using TLS, align client ssl-mode with whether the proxy expects an SSL request packet first; remove intermediate proxies that mangle the byte stream."],"exampleFix":"// before\nmysql -h proxy-host -P 3307 ... # but 3307 is the postgresql frontend port\n\n// after\nmysql -h proxy-host -P 3306 ... # connect to the MySQL frontend port","handlingStrategy":"validation","validationCode":"// Verify the endpoint speaks MySQL before connecting\ntry (Socket s = new Socket(host, port)) {\n    byte[] greeting = s.getInputStream().readNBytes(5);\n    if (greeting.length < 4 || (greeting[3] & 0xff) == 0) {\n        throw new IOException(\"Not a MySQL protocol endpoint\");\n    }\n}","typeGuard":null,"tryCatchPattern":"// Driver surfaces SQLNonTransientConnectionException wrapping error 1043;\n// do not retry — fix the client/endpoint instead:\ntry {\n    conn = DriverManager.getConnection(url, user, pass);\n} catch (SQLNonTransientConnectionException e) {\n    // check proxy WARN log hex dump; verify client version, TLS mode, and port\n    throw new IllegalStateException(\"Bad handshake: wrong port/protocol or outdated client\", e);\n}","preventionTips":["Pin clients to the correct frontend port per protocol.","Keep MySQL client libraries current (Handshake Response 41 capable).","Keep TCP probes/LB health checks from writing payload bytes into the MySQL stream."],"tags":["mysql","authentication","handshake","network","protocol"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}