{"record":{"id":"eb26857838e1f8a7","repo":"knadh/listmonk","slug":"email-column-not-found","errorCode":null,"errorMessage":"'email' column not found","messagePattern":"'email' column not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/subimporter/importer.go","lineNumber":509,"sourceCode":"\ts.im.Unlock()\n\n\t// Rewind, now that we've done a linecount on the same handler.\n\t_, _ = f.Seek(0, 0)\n\trd := csv.NewReader(f)\n\trd.Comma = delim\n\n\t// Read the header.\n\tcsvHdr, err := rd.Read()\n\tif err != nil {\n\t\ts.log.Printf(\"error reading header from '%s': '%v'\", srcPath, err)\n\t\treturn err\n\t}\n\n\thdrKeys := s.mapCSVHeaders(csvHdr, csvHeaders)\n\t// email is a required header.\n\tif _, ok := hdrKeys[\"email\"]; !ok {\n\t\ts.log.Printf(\"'email' column not found in '%s'\", srcPath)\n\t\treturn errors.New(\"'email' column not found\")\n\t}\n\n\tvar (\n\t\tlnHdr = len(hdrKeys)\n\t\ti     = 0\n\t)\n\tfor {\n\t\ti++\n\n\t\t// Check for the stop signal.\n\t\tselect {\n\t\tcase <-s.im.stop:\n\t\t\tfailed = false\n\t\t\tclose(s.subQueue)\n\t\t\ts.log.Println(\"stop request received\")\n\t\t\treturn nil\n\t\tdefault:\n\t\t}","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/knadh/listmonk/blob/670c01717d48647093335cc23a6be6f4b79c3b6b/internal/subimporter/importer.go#L491-L527","documentation":"LoadCSV parses a subscriber import CSV and requires an 'email' column to map records to subscribers. Before importing any rows it maps CSV headers to known field keys via mapCSVHeaders and checks that an 'email' header exists. If the header is missing, the import is aborted immediately with this error because no subscriber could be created or identified.","triggerScenarios":"Calling LoadCSV (or the admin import API) with a CSV file whose header row lacks an 'email' column — e.g. headers like 'mail', 'e-mail', 'Email Address', or a file with no header row at all.","commonSituations":"Exporting subscribers from another ESP with differently named columns; uploading a data-only CSV after someone deleted the header line; case/whitespace mismatches or a BOM on the first cell that break header matching.","solutions":["Add a column named exactly 'email' to the CSV header row (check for typos, extra spaces, or a BOM on the first cell).","Re-export the CSV ensuring the header row is included and the email column is labeled 'email'.","If the source system uses a different label, rename the column in the file or preprocess it before upload.","Open the first line of the file in a text editor to confirm a header row exists at all."],"exampleFix":"// before\nname,company\nJohn,Acme\n// after\nemail,name,company\njohn@acme.com,John,Acme","handlingStrategy":"validation","validationCode":"f, _ := os.Open(srcPath)\nr := csv.NewReader(f)\nhdr, err := r.Read()\nif err != nil { return err }\nfound := false\nfor _, h := range hdr {\n    if strings.EqualFold(strings.TrimSpace(h), \"email\") { found = true; break }\n}\nif !found {\n    return fmt.Errorf(\"CSV %s has no 'email' header column\", srcPath)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a header row with an exact 'email' column.","Export templates from listmonk itself to guarantee compatible headers.","Strip BOM/whitespace from the first line before upload.","Lint import files in CI with a schema check requiring 'email'."],"tags":["csv","import","validation","go"],"backgroundTag":"required-csv-column-missing","analyzedSha":"670c01717d48647093335cc23a6be6f4b79c3b6b","analyzedAt":"2026-09-01T03:39:35.452Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}