{"record":{"id":"b353e02fb713a95a","repo":"provectus/kafka-ui","slug":"input-csv-is-not-valid-there-should-be-7-columns","errorCode":null,"errorMessage":"Input csv is not valid - there should be 7 columns in line ","messagePattern":"Input csv is not valid - there should be 7 columns 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":46,"sourceCode":"  public static String createAclString(AclBinding binding) {\n    var pattern = binding.pattern();\n    var filter  = binding.toFilter().entryFilter();\n    return String.format(\n        \"%s,%s,%s,%s,%s,%s,%s\",\n        filter.principal(),\n        pattern.resourceType(),\n        pattern.patternType(),\n        pattern.name(),\n        filter.operation(),\n        filter.permissionType(),\n        filter.host()\n    );\n  }\n\n  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","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/acl/AclCsv.java#L28-L64","documentation":"AclCsv.parseCsvLine splits each ACL CSV line on the separator and requires exactly 7 columns (principal, resourceType, patternType, resourceName, operation, permission, host). When the split yields a different count, a ValidationException is thrown with the offending line number.","triggerScenarios":"Uploading/applying an ACL CSV where a line has fewer or more than 7 comma-separated fields — e.g. a missing host column, an embedded unquoted comma in the resource name, or a truncated line.","commonSituations":"Hand-edited CSVs; files exported from other tools with different column orders; missing trailing columns; stray header/footer lines; copy-paste losing a field.","solutions":["Open the CSV and make every data line contain exactly 7 comma-separated values","Fix the specific line number reported in the message","Quote fields that may contain commas or wrap the file in proper CSV quoting","Validate the file with the expected header (PRINCIPAL,RESOURCE_TYPE,...) before import"],"exampleFix":"// before\nUser:alice,Topic,read\n// after\nUser:alice,TOPIC,LITERAL,my-topic,READ,ALLOW,*","handlingStrategy":"validation","validationCode":"// Java (caller)\nboolean validLine = line.split(\",\").length == 7;\nif (!validLine) throw new IllegalArgumentException(\"ACL CSV line \" + n + \" must have 7 columns\");","typeGuard":null,"tryCatchPattern":"try {\n  Collection<AclBinding> bindings = AclCsv.parseCsv(csv);\n} catch (ValidationException e) {\n  if (e.getMessage().contains(\"7 columns\")) {\n    int lineNo = Integer.parseInt(e.getMessage().replaceAll(\".*line \", \"\"));\n    log.error(\"Fix column count on ACL CSV line {}\", lineNo);\n  } else { throw e; }\n}","preventionTips":["Keep ACL CSVs to exactly 7 columns: PRINCIPAL,RESOURCE_TYPE,PATTERN_TYPE,RESOURCE_NAME,OPERATION,PERMISSION_TYPE,HOST","Include the canonical header row so structure is self-documenting","Quote fields that may contain commas","Lint the CSV (column count + non-blank cells) before import"],"tags":["kafka","acl","csv","validation"],"backgroundTag":"schema-validation-failed","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"}