{"record":{"id":"8d94d0c799fa7182","repo":"provectus/kafka-ui","slug":"error-parsing-enum-value-in-line","errorCode":null,"errorMessage":"Error parsing enum value in line ","messagePattern":"Error parsing enum value in line ","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/acl/AclCsv.java","lineNumber":61,"sourceCode":"  private static AclBinding parseCsvLine(String csv, int line) {\n    String[] values = csv.split(VALUES_SEPARATOR);\n    if (values.length != 7) {\n      throw new ValidationException(\"Input csv is not valid - there should be 7 columns in line \" + line);\n    }\n    for (int i = 0; i < values.length; i++) {\n      if ((values[i] = values[i].trim()).isBlank()) {\n        throw new ValidationException(\"Input csv is not valid - blank value in colum \" + i + \", line \" + line);\n      }\n    }\n    try {\n      return new AclBinding(\n          new ResourcePattern(\n              ResourceType.valueOf(values[1]), values[3], PatternType.valueOf(values[2])),\n          new AccessControlEntry(\n              values[0], values[6], AclOperation.valueOf(values[4]), AclPermissionType.valueOf(values[5]))\n      );\n    } catch (IllegalArgumentException enumParseError) {\n      throw new ValidationException(\"Error parsing enum value in line \" + line);\n    }\n  }\n\n  public static Collection<AclBinding> parseCsv(String csvString) {\n    String[] lines = csvString.split(LINE_SEPARATOR);\n    if (lines.length == 0) {\n      throw new ValidationException(\"Error parsing ACL csv file: no lines in file\");\n    }\n    boolean firstLineIsHeader = HEADER.equalsIgnoreCase(lines[0].trim().replace(\" \", \"\"));\n    Set<AclBinding> result = new HashSet<>();\n    for (int i = firstLineIsHeader ? 1 : 0; i < lines.length; i++) {\n      String line = lines[i];\n      if (!line.isBlank()) {\n        AclBinding aclBinding = parseCsvLine(line, i);\n        result.add(aclBinding);\n      }\n    }\n    return result;","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/acl/AclCsv.java#L43-L79","documentation":"AclCsv.parseCsvLine builds a Kafka AclBinding using ResourceType, PatternType, AclOperation and AclPermissionType enums via valueOf. If any of these strings is not a valid enum constant, the caught IllegalArgumentException is rethrown as 'Error parsing enum value in line <n>'.","triggerScenarios":"CSV containing misspelled or lowercase enum values, e.g. resourceType 'topic' instead of 'TOPIC', operation 'read' instead of 'READ', or an unknown pattern type.","commonSituations":"CSVs written by hand or generated by tools using different naming conventions; older Kafka enum names; translated/localized field values; case-sensitivity mistakes.","solutions":["Use exact uppercase Kafka enum names: ResourceType (TOPIC, GROUP, ...), PatternType (LITERAL, PREFIXED, ...), AclOperation (READ, WRITE, ALL, ...), AclPermissionType (ALLOW, DENY)","Check case-sensitivity — valueOf is exact-match","Inspect line number in the message and fix only that line","Generate the CSV from a template with fixed enum columns"],"exampleFix":"// before\nUser:alice,topic,LITERAL,my-topic,read,allow,*\n// after\nUser:alice,TOPIC,LITERAL,my-topic,READ,ALLOW,*","handlingStrategy":"validation","validationCode":"// Java (caller)\nSet<String> resTypes = Set.of(\"TOPIC\",\"GROUP\",\"CLUSTER\",\"TRANSACTIONAL_ID\",\"DELEGATION_TOKEN\");\nSet<String> patternTypes = Set.of(\"LITERAL\",\"PREFIXED\",\"ANY\",\"MATCH\",\"TYPE\");\nSet<String> ops = Set.of(\"READ\",\"WRITE\",\"CREATE\",\"DELETE\",\"ALTER\",\"DESCRIBE\",\"ALL\", /* ... */);\nSet<String> perms = Set.of(\"ALLOW\",\"DENY\",\"ANY\");\n// check values[i] for i in {1,2,4,5} against these sets before parsing","typeGuard":null,"tryCatchPattern":"try {\n  Collection<AclBinding> bindings = AclCsv.parseCsv(csv);\n} catch (ValidationException e) {\n  if (e.getMessage().startsWith(\"Error parsing enum value\")) {\n    log.error(\"Invalid enum name in ACL CSV: {}\", e.getMessage()); // fix case/spelling\n  } else { throw e; }\n}","preventionTips":["Use exact uppercase Kafka enum names (TOPIC, LITERAL, READ, ALLOW, ...) — valueOf is case-sensitive","Generate ACL CSVs from a fixed template with validated enum columns","Cross-check enum names against your Kafka clients version's API docs","Normalize input (toUpperCase + trim) before writing the CSV"],"tags":["kafka","acl","csv","enum"],"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"}