provectus/kafka-ui · error · ValidationException
' ' is not valid json
Error message
'%s' is not valid json
What it means
serializeJson first parses the supplied value with a JSON mapper before validating it against the registered JSON Schema. If the string cannot be parsed as JSON at all, it throws this ValidationException instead of a schema error, telling you the value is syntactically invalid JSON.
Solutions
- Validate the value with a JSON parser (jq, jsonlint) before producing
- Ensure string values are quoted, e.g. "my value" not my value
- Verify shell/curl quoting didn't strip or double-escape quotes in API calls
- Check the value string in the error message to see exactly what failed parsing
Example fix
// before
String value = "{'key': 'val'}"; // single quotes are invalid JSON
// after
String value = "{\"key\": \"val\"}"; Defensive patterns
Strategy: validation
Validate before calling
ObjectMapper m = new ObjectMapper();
try { m.readTree(value); } catch (JsonProcessingException e) {
throw new IllegalArgumentException("value is not valid JSON: " + e.getOriginalMessage());
} Try / catch
try {
produceMessage(topic, value);
} catch (ValidationException e) {
// value failed JSON parsing; surface message before retry
System.err.println(e.getMessage());
} Prevention
- Run jq or a JSON linter over the payload before producing
- In API calls, put the JSON in a properly quoted field and verify shell escaping
- Build payloads with a JSON library (Jackson, Gson) rather than string concatenation
When it happens
Trigger: Producing via the kafka-ui messages API with the Json (Schema Registry JSON schema) serde and a value parameter that fails Jackson readTree parsing - e.g. single quotes instead of double quotes, missing quotes around strings, trailing commas, unescaped control characters, or plain text.
Common situations: Hand-typing a value in the UI produce form without proper JSON quoting; shell/curl quoting mangled the JSON body; copied values that got double-escaped or unescaped; sending a bare string or number without valid JSON syntax.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- ' ' does not fit schema
- seekTo should be set if seekType is
- Serde can't be applied for ' ' topic's serialization
- Something went wrong during adding replicas
- Something went wrong during removing replicas
AI-assisted analysis of provectus/kafka-ui@83b5a60cc0 (2026-09-08).
Data as JSON: /api/errors/e7eecbf01068deeb.
Report an issue: GitHub.
Appendix: source
Thrown at kafka-ui-api/src/main/java/com/provectus/kafka/ui/serdes/builtin/sr/Serialize.java:47
import org.apache.avro.io.DatumWriter;
import org.apache.avro.io.EncoderFactory;
final class Serialize {
private static final byte MAGIC = 0x0;
private static final ObjectMapper JSON_SERIALIZE_MAPPER = Jackson.newObjectMapper(); //from confluent package
private Serialize() {
}
@KafkaClientInternalsDependant("AbstractKafkaJsonSchemaSerializer::serializeImpl")
@SneakyThrows
static byte[] serializeJson(JsonSchema schema, int schemaId, String value) {
JsonNode json;
try {
json = JSON_SERIALIZE_MAPPER.readTree(value);
} catch (JsonProcessingException e) {
throw new ValidationException(String.format("'%s' is not valid json", value));
}
try {
schema.validate(json);
} catch (org.everit.json.schema.ValidationException e) {
throw new ValidationException(
String.format("'%s' does not fit schema: %s", value, e.getAllMessages()));
}
try (var out = new ByteArrayOutputStream()) {
out.write(MAGIC);
out.write(schemaId(schemaId));
out.write(JSON_SERIALIZE_MAPPER.writeValueAsBytes(json));
return out.toByteArray();
}
}
@KafkaClientInternalsDependant("AbstractKafkaProtobufSerializer::serializeImpl")
@SneakyThrows
static byte[] serializeProto(SchemaRegistryClient srClient,View on GitHub (pinned to 83b5a60cc0)