{"record":{"id":"c775418ad61cc5a3","repo":"provectus/kafka-ui","slug":"serde-s-can-t-be-applied-to-s-topic-s","errorCode":null,"errorMessage":"Serde '%s' can't be applied to '%s' topic %s","messagePattern":"Serde '(.+?)' can't be applied to '(.+?)' topic (.+?)","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/DeserializationService.java","lineNumber":72,"sourceCode":"        .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;\n    } else {\n      return serdes.suggestSerdeForDeserialize(topic, type);\n    }\n  }\n\n  public ProducerRecordCreator producerRecordCreator(KafkaCluster cluster,\n                                                     String topic,\n                                                     String keySerdeName,\n                                                     String valueSerdeName) {\n    return new ProducerRecordCreator(\n        getSerializer(cluster, topic, Serde.Target.KEY, keySerdeName),\n        getSerializer(cluster, topic, Serde.Target.VALUE, valueSerdeName)\n    );\n  }\n","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/DeserializationService.java#L54-L90","documentation":"getSerdeForDeserialize validates the explicitly requested serdeName against the topic and type (key or value) via canDeserialize. If the serde exists but cannot deserialize that side of that topic, this ValidationException is thrown; when no name is given, kafka-ui auto-suggests a suitable serde instead.","triggerScenarios":"Requesting message consumption/preview with an explicit keySerde or valueSerde query parameter whose canDeserialize(topic, type) is false - e.g. asking an Avro Schema Registry serde to deserialize the key of a topic whose key subject/mapping doesn't exist, or using a serde that only supports VALUE.","commonSituations":"Saved UI links/queries carrying a serde name from a different topic; topic renamed or schema subject mappings changed after the query was bookmarked; swapping keySerde and valueSerde parameters in an API call; cluster migration where the new cluster lacks the subject for that topic.","solutions":["Omit the keySerde/valueSerde parameter so kafka-ui auto-suggests a suitable serde for the topic","Pick a serde that supports that topic side, e.g. String for non-registry-encoded keys","If using SR-based serdes, confirm the subject/mapping for this topic (and key vs value) exists in Schema Registry","Re-check the request: ensure a value-side serde wasn't passed as keySerde or vice versa"],"exampleFix":"// before\nGET /api/clusters/c1/topics/t/messages?valueSerde=Avro // Avro can't deserialize this topic's values\n// after\nGET /api/clusters/c1/topics/t/messages // let kafka-ui suggest the serde\n// or pick a compatible serde explicitly\nGET /api/clusters/c1/topics/t/messages?valueSerde=String","handlingStrategy":"validation","validationCode":"var serdes = deserializationService.getSerdesFor(cluster);\nboolean usable = serdes.serdeForName(serdeName)\n    .map(s -> s.canDeserialize(topic, type))\n    .orElse(false);\nif (!usable) serdeName = null; // let kafka-ui suggest one","typeGuard":null,"tryCatchPattern":"try {\n  messages = kafkaUiApi.getMessages(topic, keySerde, valueSerde);\n} catch (ValidationException e) {\n  if (e.getMessage().contains(\"can't be applied\")) {\n    messages = kafkaUiApi.getMessages(topic, null, null); // auto-suggest serdes\n  }\n}","preventionTips":["Prefer omitting keySerde/valueSerde and let kafka-ui suggest serdes per topic","Refresh saved consumption queries after topic/schema config changes","Verify key vs value serde parameters aren't swapped in API calls"],"tags":["kafka","serde","deserialization","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"}