You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "mayur mohan (Jira)" <ji...@apache.org> on 2026/08/28 02:13:00 UTC

[jira] [Commented] (CAMEL-24546) camel-csv: wrap CSV parse IOException with diagnostic message in CsvUnmarshaller

    [ https://issues.apache.org/jira/browse/CAMEL-24546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18109031#comment-18109031 ] 

mayur mohan commented on CAMEL-24546:
-------------------------------------

Fix implemented in PR https://github.com/apache/camel/pull/25845

Changes:
- Added wrapCsvParseError() helper to CsvUnmarshaller wrapping IOException and UncheckedIOException from Commons CSV with a diagnostic message
- Both BulkCsvUnmarshaller catch blocks (IOException at construction and UncheckedIOException during eager iteration) now produce clearer error messages
- Added CsvUnmarshalErrorMessageTest with 3 tests (all passing locally with JDK 21)

_Claude Code on behalf of mayurbm_

> camel-csv: wrap CSV parse IOException with diagnostic message in CsvUnmarshaller
> --------------------------------------------------------------------------------
>
>                 Key: CAMEL-24546
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24546
>             Project: Camel
>          Issue Type: Improvement
>            Reporter: mayur mohan
>            Priority: Minor
>
> When camel-csv unmarshal encounters malformed CSV input (e.g. a quoted field with extra characters after the closing quote), Apache Commons CSV throws a raw IOException with a technical message that is hard to diagnose for operators.
> *Observed error:*
> {noformat}
> java.io.IOException: (line 1) invalid char between encapsulated token and delimiter
>     at org.apache.commons.csv.Lexer.parseEncapsulatedToken(Lexer.java:281)
>     at org.apache.commons.csv.Lexer.nextToken(Lexer.java:158)
>     at org.apache.commons.csv.CSVParser.nextRecord(CSVParser.java:674)
>     at org.apache.commons.csv.CSVParser.createHeaders(CSVParser.java:483)
>     at org.apache.commons.csv.CSVParser.<init>(CSVParser.java:412)
>     at org.apache.commons.csv.CSVParser.<init>(CSVParser.java:378)
>     at org.apache.camel.dataformat.csv.CsvUnmarshaller$BulkCsvUnmarshaller.unmarshal(CsvUnmarshaller.java:105)
>     at org.apache.camel.dataformat.csv.CsvDataFormat.unmarshal(CsvDataFormat.java:95)
>     at com.sap.it.rt.csvtoxml.converter.internal.CsvToJavaListConverter.unmarshalCsv(CsvToJavaListConverter.java:57)
>     at com.sap.it.rt.csvtoxml.converter.CsvToXmlProcessor.process(CsvToXmlProcessor.java:79)
>     at org.apache.camel.support.ObjectHelper.invokeMethodSafe(ObjectHelper.java:403)
>     at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:494)
>     at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:316)
>     at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:286)
>     at org.apache.camel.component.bean.AbstractBeanProcessor.process(AbstractBeanProcessor.java:146)
>     at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:81)
>     at org.apache.camel.support.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:104)
>     at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.doRun(RedeliveryErrorHandler.java:818)
>     at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.run(RedeliveryErrorHandler.java:726)
>     at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:193)
>     at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64)
>     at org.apache.camel.processor.Pipeline.process(Pipeline.java:185)
>     at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398)
> {noformat}
> Line 1 is usually the header. A quoted field was closed, then extra characters appeared before the delimiter (example: {{"OrderId"x,"Name"}}).
> *File:* {{components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvUnmarshaller.java}}
> Classes: {{BulkCsvUnmarshaller}}, {{StreamCsvUnmarshaller}}
> *Proposed fix:*
> Add a {{wrapCsvParseError(IOException)}} helper in {{CsvUnmarshaller}} that detects the encapsulated-token message and wraps it with a human-readable explanation. Both {{BulkCsvUnmarshaller.unmarshal}} and {{StreamCsvUnmarshaller.unmarshal}} call this helper on caught {{IOException}}.
> *Error message after fix:*
> {noformat}
> CSV parse failed: (line 1) invalid char between encapsulated token and delimiter. A quoted field has extra characters after the closing quote and before the delimiter (example: "abc"x,def). Check delimiter, quote character, and escaped quotes ("").
> {noformat}
> This is a cosmetic/diagnostic-only change. No behavior, API, or data format change. Bad CSV still fails — it just fails with a clearer message.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)