{"record":{"id":"4e14e965580b7dfa","repo":"grafana/k6","slug":"failed-to-skip-the-first-line-reason-w","errorCode":null,"errorMessage":"failed to skip the first line; reason: %w","messagePattern":"failed to skip the first line; reason: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/experimental/csv/reader.go","lineNumber":70,"sourceCode":"\n\treader := &Reader{\n\t\tcsv:     csvParser,\n\t\toptions: options,\n\t}\n\n\tasObjectsEnabled := options.AsObjects.Valid && options.AsObjects.Bool\n\tif asObjectsEnabled {\n\t\theader, err := csvParser.Read()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read the first line; reason: %w\", err)\n\t\t}\n\t\treader.columnNames = header\n\t\treader.currentLine.Add(1)\n\t}\n\n\tif options.SkipFirstLine && (!options.FromLine.Valid || options.FromLine.Int64 == 0) {\n\t\tif _, err := csvParser.Read(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to skip the first line; reason: %w\", err)\n\t\t}\n\n\t\treader.currentLine.Add(1)\n\t}\n\n\tif options.FromLine.Valid && options.FromLine.Int64 > 0 {\n\t\tfor reader.currentLine.Load() < options.FromLine.Int64 {\n\t\t\tif _, err := csvParser.Read(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to skip lines until line %d; reason: %w\", options.FromLine.Int64, err)\n\t\t\t}\n\t\t\treader.currentLine.Add(1)\n\t\t}\n\t}\n\n\treturn reader, nil\n}\n\n// The csv module's read must implement the RecordReader interface.","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/experimental/csv/reader.go#L52-L88","documentation":"Raised in NewReaderFrom when skipFirstLine is true (and fromLine is unset or 0) and consuming the first record via encoding/csv fails. The wrapped error (io.EOF for an empty file, or a csv.ParseError) carries the actual reason.","triggerScenarios":"Thrown at internal/js/modules/k6/experimental/csv/reader.go:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the file has at least one line to skip when skipFirstLine is true","Fix CSV syntax errors such as stray quotes in the first line","Remove skipFirstLine if the file is empty or has no disposable header"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}