{"record":{"id":"30f9a875df9fade6","repo":"elastic/elasticsearch","slug":"character-after-quoted-field-at","errorCode":null,"errorMessage":"character '{}' after quoted field at {}","messagePattern":"character '(.+?)' after quoted field at (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CsvParser.java","lineNumber":169,"sourceCode":"        boolean shouldSetField = true;\n        for (; currentIndex < length; currentIndex++) {\n            c = currentChar();\n            if (c == separator) {\n                if (shouldSetField && setField(currentIndex - 1)) {\n                    return true;\n                }\n                startIndex = currentIndex + 1;\n                state = State.START;\n                return false;\n            } else if (isWhitespace(c)) {\n                if (shouldSetField) {\n                    if (setField(currentIndex - 1)) {\n                        return true;\n                    }\n                    shouldSetField = false;\n                }\n            } else {\n                throw new IllegalArgumentException(\"character '\" + c + \"' after quoted field at \" + currentIndex);\n            }\n        }\n        return true;\n    }\n\n    private char currentChar() {\n        return line.charAt(currentIndex);\n    }\n\n    private static boolean isWhitespace(char c) {\n        return c == SPACE || c == TAB;\n    }\n\n    private boolean setField(int endIndex) {\n        String value;\n        if (builder.length() == 0) {\n            value = line.substring(startIndex, endIndex);\n        } else {","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CsvParser.java#L151-L187","documentation":"Thrown by CsvParser when, after a closing quote of a quoted field, it encounters a character that is neither whitespace (space/tab) nor the field separator nor a line terminator. The parser allows trailing whitespace after a closing quote but any other character (a second quote, a letter, etc.) is invalid CSV and is rejected with the offending character and its position.","triggerScenarios":"Input like \"abc\"def,123 or \"abc\"x where text follows the closing quote of a quoted field. The first character after the closing quote that is not space/tab/separator triggers the error at that index.","commonSituations":"Concatenated fields where a producer forgot the separator; CSV where quotes were intended as literal characters but placed adjacent to a quoted value; copy-paste concatenation of partial CSV rows; malformed exports that append a unit or currency symbol after a quoted value.","solutions":["Inspect the input at the reported character index and fix the producer's quoting/separator logic.","Use a gsub processor to insert the configured separator where it is missing.","Quarantine the malformed record with an on_failure block for offline repair."],"exampleFix":"// before - input: \"price\"USD,12.5  (text immediately after closing quote)\n{\"csv\": {\"field\": \"message\", \"target_fields\": [\"label\",\"amount\"]}}\n// after - producer must separate fields correctly: \"price\",USD,12.5\n// (fix at source; or pre-clean with gsub if pattern is predictable)","handlingStrategy":"validation","validationCode":"// Validate that closing quotes are followed only by whitespace, separator, or end-of-line:\n{\"script\": {\"source\": \"if (ctx.message =~ /\\\"[^\\\"\\r\\n, \\t]/) { throw new Exception('char after quoted field'); }\"}}","typeGuard":null,"tryCatchPattern":"{\"on_failure\": [{\"index\": {\"index\": \"csv-dlq\"}}]}","preventionTips":["Fix producer quoting so separators always separate fields after a closing quote.","Pre-clean with gsub if you can identify the corruption pattern.","Quarantine malformed records."],"tags":["ingest","csv-processor","csv-parsing","data-quality"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}