{"record":{"id":"d0713a596c559fcd","repo":"dianping/cat","slug":"unsupported-message-type-s","errorCode":null,"errorMessage":"Unsupported message type: %s.","messagePattern":"Unsupported message type: (.+?)\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"cat-core/src/main/java/com/dianping/cat/message/codec/HtmlMessageCodec.java","lineNumber":251,"sourceCode":"\t\t\t}\r\n\t\t} else if (message instanceof Event) {\r\n\t\t\tString type = message.getType();\r\n\r\n\t\t\tif (\"RemoteCall\".equals(type)) {\r\n\t\t\t\treturn encodeLogViewLink(tree, message, buf, level, counter);\r\n\t\t\t} else if (\"RemoteLink\".equals(type)) {\r\n\t\t\t\treturn encodeRemoteLink(tree, message, buf, level, counter);\r\n\t\t\t} else {\r\n\t\t\t\treturn encodeLine(tree, message, buf, 'E', Policy.DEFAULT, level, counter);\r\n\t\t\t}\r\n\t\t} else if (message instanceof Trace) {\r\n\t\t\treturn encodeLine(tree, message, buf, 'L', Policy.DEFAULT, level, counter);\r\n\t\t} else if (message instanceof Metric) {\r\n\t\t\treturn encodeLine(tree, message, buf, 'M', Policy.DEFAULT, level, counter);\r\n\t\t} else if (message instanceof Heartbeat) {\r\n\t\t\treturn encodeLine(tree, message, buf, 'H', Policy.DEFAULT, level, counter);\r\n\t\t} else {\r\n\t\t\tthrow new RuntimeException(String.format(\"Unsupported message type: %s.\", message.getClass()));\r\n\t\t}\r\n\t}\r\n\r\n\tprotected int encodeRemoteLink(MessageTree tree, Message message, ByteBuf buf, int level, LineCounter counter) {\r\n\t\tBufferHelper helper = m_bufferHelper;\r\n\t\tint count = 0;\r\n\r\n\t\tif (counter != null) {\r\n\t\t\tcounter.inc();\r\n\r\n\t\t\tcount += helper.tr1(buf, \"link\");\r\n\t\t} else {\r\n\t\t\tcount += helper.tr1(buf, null);\r\n\t\t}\r\n\r\n\t\tString link = message.getData().toString();\r\n\t\tString name = message.getName();\r\n\r","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-core/src/main/java/com/dianping/cat/message/codec/HtmlMessageCodec.java#L233-L269","documentation":"HtmlMessageCodec.encodeMessage walks the message tree rendering HTML and throws RuntimeException(\"Unsupported message type: <class>.\") when a message is none of Transaction/Event/Trace/Metric/Heartbeat (and not the special RemoteLink event type). It means a custom or newer Message implementation reached the HTML renderer, which only knows the built-in types.","triggerScenarios":"Encoding a MessageTree that contains a user class implementing Message directly (instead of extending DefaultEvent/DefaultTransaction etc.), or a message type added in a newer CAT version being rendered by an older HtmlMessageCodec.","commonSituations":"Custom message implementations injected by plugins; mixing CAT client/server versions so new message kinds hit an old HTML view; test fixtures with mock Message objects that are not subclasses of the known types.","solutions":["Check the class name in the exception message; it names the exact unsupported type.","Make custom messages subclass one of the supported base types (DefaultEvent, DefaultTransaction, DefaultMetric, DefaultHeartbeat, DefaultTrace).","Upgrade cat-core so the HTML codec knows any newer built-in message types.","Filter unknown message types out of the tree before HTML rendering if they cannot be represented."],"exampleFix":"// before\nclass MyMessage implements Message { ... } // encoded -> throws\n\n// after\nclass MyMessage extends DefaultEvent { ... } // renders as event line 'E'","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static String htmlKind(Message m) {\n    if (m instanceof Transaction) return \"t\";\n    if (m instanceof Event || m instanceof Trace || m instanceof Metric || m instanceof Heartbeat) return \"ok\";\n    return null; // unsupported\n}","tryCatchPattern":"catch (RuntimeException e) { if (e.getMessage().startsWith(\"Unsupported message type\")) renderFallback(tree); else throw e; }","preventionTips":["Subclass Default* message types for custom data instead of implementing Message.","Version-check both ends before enabling new message kinds."],"tags":["encoding","html","message-tree","polymorphism"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}