{"record":{"id":"b666b0bb973ead9c","repo":"provectus/kafka-ui","slug":"4002","errorCode":"4002","errorMessage":"%s is not a part of enum symbols [%s]","messagePattern":"(.+?) is not a part of enum symbols \\[(.+?)\\]","errorType":"validation","errorClass":"JsonAvroConversionException","httpStatus":400,"severity":"error","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/util/jsonschema/JsonAvroConversion.java","lineNumber":90,"sourceCode":"      }\n      case MAP -> {\n        assertJsonType(node, JsonNodeType.OBJECT);\n        var map = new LinkedHashMap<String, Object>();\n        var valueSchema = avroSchema.getValueType();\n        node.fields().forEachRemaining(f -> map.put(f.getKey(), convert(f.getValue(), valueSchema)));\n        yield map;\n      }\n      case ARRAY -> {\n        assertJsonType(node, JsonNodeType.ARRAY);\n        var lst = new ArrayList<>();\n        node.elements().forEachRemaining(e -> lst.add(convert(e, avroSchema.getElementType())));\n        yield lst;\n      }\n      case ENUM -> {\n        assertJsonType(node, JsonNodeType.STRING);\n        String symbol = node.textValue();\n        if (!avroSchema.getEnumSymbols().contains(symbol)) {\n          throw new JsonAvroConversionException(\"%s is not a part of enum symbols [%s]\"\n              .formatted(symbol, avroSchema.getEnumSymbols()));\n        }\n        yield new GenericData.EnumSymbol(avroSchema, symbol);\n      }\n      case UNION -> {\n        // for types from enum (other than null) payload should be an object with single key == name of type\n        // ex: schema = [ \"null\", \"int\", \"string\" ], possible payloads = null, { \"string\": \"str\" },  { \"int\": 123 }\n        if (node.isNull() && avroSchema.getTypes().contains(NULL_SCHEMA)) {\n          yield null;\n        }\n\n        assertJsonType(node, JsonNodeType.OBJECT);\n        var elements = Lists.newArrayList(node.fields());\n        if (elements.size() != 1) {\n          throw new JsonAvroConversionException(\n              \"UNION field value should be an object with single field == type name\");\n        }\n        Map.Entry<String, JsonNode> typeNameToValue = elements.get(0);","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/util/jsonschema/JsonAvroConversion.java#L72-L108","documentation":"When converting a JSON node to an Avro ENUM schema, convert() checks the string value against the schema's declared enum symbols (avroSchema.getEnumSymbols()). If the string is not one of the declared symbols, a JsonAvroConversionException with code 4002 is thrown. This enforces Avro's rule that enum values must exactly match a symbol defined in the schema.","triggerScenarios":"Producing a message whose field maps to an Avro enum type with a value not present in the schema's symbols list, e.g. JSON \"state\": \"IDLE\" when the schema only declares symbols [\"RUNNING\",\"STOPPED\"]. Case differences (\"running\" vs \"RUNNING\") also trigger it.","commonSituations":"Schema evolution: a producer sends a value that was valid under an older schema version but is absent from the current one; typos or wrong casing when hand-writing payloads in kafka-ui's produce form.","solutions":["Inspect the Avro schema's enum symbols and use one of the exact declared strings (case-sensitive).","If the new value is legitimate, update/register a new schema version that includes the symbol.","Normalize the payload value's casing/whitespace to match the schema symbols exactly."],"exampleFix":"// before\n{\"state\": \"idle\"}  // schema symbols: [\"IDLE\", \"RUNNING\"]\n\n// after\n{\"state\": \"IDLE\"}","handlingStrategy":"validation","validationCode":"Set<String> symbols = new HashSet<>(avroSchema.getEnumSymbols());\nif (!symbols.contains(jsonValue)) {\n  throw new IllegalArgumentException(jsonValue + \" not in enum symbols \" + symbols);\n}","typeGuard":"boolean isValidEnumValue(JsonNode node, Schema enumSchema) {\n  return node.isTextual() && enumSchema.getEnumSymbols().contains(node.textValue());\n}","tryCatchPattern":"try {\n  Object avro = JsonAvroConversion.convertJsonToAvro(json, schema);\n} catch (JsonAvroConversionException e) {\n  // message contains '<value> is not a part of enum symbols' -> fix or remap the value\n}","preventionTips":["Generate payload enums from the schema's symbol list, not free-form strings.","Remember enum matching is case-sensitive and whitespace-sensitive.","After schema evolution, re-validate old payloads against the new symbol set."],"tags":["avro","enum","validation","schema"],"backgroundTag":"invalid-enum-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"}