{"record":{"id":"74ae93e429abef23","repo":"provectus/kafka-ui","slug":"serde-s-can-t-be-applied-for-s-topic-s-s-seri","errorCode":null,"errorMessage":"Serde %s can't be applied for '%s' topic's %s serialization","messagePattern":"Serde (.+?) can't be applied for '(.+?)' topic's (.+?) serialization","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/DeserializationService.java","lineNumber":57,"sourceCode":"      var cluster = clustersStorage.getClusterByName(clusterProperties.getName()).get();\n      clusterSerdes.put(cluster.getName(), serdesInitializer.init(env, clustersProperties, i));\n    }\n  }\n\n  private ClusterSerdes getSerdesFor(KafkaCluster cluster) {\n    return clusterSerdes.get(cluster.getName());\n  }\n\n  private Serde.Serializer getSerializer(KafkaCluster cluster,\n                                         String topic,\n                                         Serde.Target type,\n                                         String serdeName) {\n    var serdes = getSerdesFor(cluster);\n    var serde = serdes.serdeForName(serdeName)\n        .orElseThrow(() -> new ValidationException(\n            String.format(\"Serde %s not found\", serdeName)));\n    if (!serde.canSerialize(topic, type)) {\n      throw new ValidationException(\n          String.format(\"Serde %s can't be applied for '%s' topic's %s serialization\", serde, topic, type));\n    }\n    return serde.serializer(topic, type);\n  }\n\n  private SerdeInstance getSerdeForDeserialize(KafkaCluster cluster,\n                                               String topic,\n                                               Serde.Target type,\n                                               @Nullable String serdeName) {\n    var serdes = getSerdesFor(cluster);\n    if (serdeName != null) {\n      var serde = serdes.serdeForName(serdeName)\n          .orElseThrow(() -> new ValidationException(String.format(\"Serde '%s' not found\", serdeName)));\n      if (!serde.canDeserialize(topic, type)) {\n        throw new ValidationException(\n            String.format(\"Serde '%s' can't be applied to '%s' topic %s\", serdeName, topic, type));\n      }\n      return serde;","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/DeserializationService.java#L39-L75","documentation":"DeserializationService.getSerializer looks up the requested serde by name and then checks serde.canSerialize(topic, type) before returning a serializer. This error means the serde exists but explicitly does not support serializing the requested type (key or value) for that topic, so producing with it is refused.","triggerScenarios":"POSTing to the kafka-ui messages produce endpoint with a serdeName whose canSerialize(topic, type) returns false - e.g. a Schema Registry serde for a topic with no compatible subject mapping, or a proto/avro serde where the topic/message-type selection doesn't match.","commonSituations":"Selecting the wrong serde in the UI produce form; key vs value mismatch in the type parameter; builtin serde that requires a configured topic-to-schema mapping, but the mapping doesn't cover this topic name; reusing a serde name copied from another cluster/topic.","solutions":["Use a serde that supports the topic and type: pick String or Json for generic values, or configure the SR/Protobuf serde's topic mapping so canSerialize passes","Check that the correct type (key vs value) is selected for the serde in the produce request","Verify the serde's template-based configuration actually covers this topic name"],"exampleFix":"// before\n{\"serdeName\":\"SchemaRegistry\",\"topic\":\"events\",\"type\":\"VALUE\",\"value\":\"...\"} // serde not applicable to this topic\n// after\n{\"serdeName\":\"String\",\"topic\":\"events\",\"type\":\"VALUE\",\"value\":\"...\"} // or configure SR mapping for 'events'","handlingStrategy":"try-catch","validationCode":"var serdes = deserializationService.getSerdesFor(cluster);\nboolean ok = serdes.serdeForName(serdeName)\n    .map(s -> s.canSerialize(topic, type))\n    .orElse(false);\nif (!ok) { /* pick another serde or configure the mapping */ }","typeGuard":null,"tryCatchPattern":"try {\n  kafkaUiApi.produce(topic, serdeName, type, value);\n} catch (ValidationException e) {\n  if (e.getMessage().contains(\"can't be applied\")) {\n    // fall back to String serde or reconfigure the serde mapping\n  }\n}","preventionTips":["Query getSerdesFor for which serdes are usable for this topic/type before producing","Keep topic-to-schema/template mappings in serde config in sync with actual topic names","In UI flows, use serde names returned by the API rather than hardcoding them"],"tags":["kafka","serde","serialization","configuration"],"backgroundTag":"invalid-argument-value","analyzedSha":"83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7","analyzedAt":"2026-09-08T04:35:39.002Z","contentChangedAt":"2026-09-08T04:35:39.002Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}