{"record":{"id":"3b340a43eaaae8d5","repo":"junit-team/junit5","slug":"failed-to-parse-csv-input-configured-via-s","errorCode":null,"errorMessage":"Failed to parse CSV input configured via %s","messagePattern":"Failed to parse CSV input configured via (.+?)","errorType":"exception","errorClass":"CsvParsingException","httpStatus":null,"severity":"error","filePath":"junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvArgumentsProvider.java","lineNumber":144,"sourceCode":"\t\treturn ((NamedCsvRecord) record).getHeader();\n\t}\n\n\t@SuppressWarnings({ \"ReferenceEquality\", \"StringEquality\" })\n\tprivate static @Nullable String resolveNullMarker(String record) {\n\t\treturn record == CsvReaderFactory.DefaultFieldModifier.NULL_MARKER ? null : record;\n\t}\n\n\t/**\n\t * @return this method always throws an exception and therefore never\n\t * returns anything; the return type is merely present to allow this\n\t * method to be supplied as the operand in a {@code throw} statement\n\t */\n\tstatic RuntimeException handleCsvException(Throwable throwable, Annotation annotation) {\n\t\tUnrecoverableExceptions.rethrowIfUnrecoverable(throwable);\n\t\tif (throwable instanceof PreconditionViolationException exception) {\n\t\t\tthrow exception;\n\t\t}\n\t\tthrow new CsvParsingException(\"Failed to parse CSV input configured via \" + annotation, throwable);\n\t}\n\n}\n","sourceCodeStart":126,"sourceCodeEnd":148,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvArgumentsProvider.java#L126-L148","documentation":"Thrown by CsvArgumentsProvider.handleCsvException when CSV parsing fails for any reason other than a PreconditionViolationException. It first rethrows unrecoverable errors and PreconditionViolationException as-is, then wraps all remaining throwables in a CsvParsingException naming the source annotation. The annotation in the message identifies which @CsvSource/@CsvFileSource configured the input.","triggerScenarios":"Malformed CSV rows, wrong delimiter, unescaped quotes, column count mismatch, or invalid number/boolean tokens while parsing arguments from @CsvSource. Any underlying parse Throwable that is not a PreconditionViolationException reaches the final throw.","commonSituations":"Typo in CSV literal (extra comma, missing quote). Mismatch between the number of CSV columns and the @ParameterizedTest parameter count. Wrong delimiter or empty-quote configuration on @CsvSource. Non-numeric value supplied for a numeric parameter.","solutions":["Inspect the wrapped cause for the precise parse error (line/column).","Verify each CSV row has the correct number of columns for the test parameters.","Check @CsvSource attributes: delimiter, quoteChar, emptyValue, nullValues, and column count.","Escape quotes by doubling them and ensure no stray delimiters."],"exampleFix":"// before\n@CsvSource({\n  \"1, 'a\",\n  \"2, b\"\n})\n\n// after\n@CsvSource({\n  \"1, 'a'\",\n  \"2, 'b'\"\n})","handlingStrategy":"try-catch","validationCode":"// Pre-validate CSV rows against the expected column count and types\nString delimiter = \",\";\nint expectedCols = 3;\nfor (String row : csvRows) {\n    String[] cols = row.split(delimiter, -1);\n    if (cols.length != expectedCols)\n        throw new IllegalArgumentException(\"Bad CSV row: \" + row);\n}","typeGuard":null,"tryCatchPattern":"try {\n    runParameterizedTest();\n} catch (CsvParsingException e) {\n    // e.getCause() holds the underlying parse error with line/column\n    fail(\"CSV parse failure: \" + e.getCause().getMessage());\n}","preventionTips":["Keep CSV column counts aligned with the @ParameterizedTest parameter count.","Double any literal quotes in CSV; verify delimiter/quoteChar on @CsvSource.","Unit-test CSV literals in a scratch test before committing them."],"tags":["junit-jupiter","csv","parameterized-test","parsing"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}