Skip to content

Issue #8000 : Route unreadable XML files to error handling - #8029

Merged
hansva merged 2 commits into
apache:mainfrom
vbhanuchander-lang:issue-8000-xml-file-error-handling
Aug 21, 2026
Merged

Issue #8000 : Route unreadable XML files to error handling#8029
hansva merged 2 commits into
apache:mainfrom
vbhanuchander-lang:issue-8000-xml-file-error-handling

Conversation

@vbhanuchander-lang

Copy link
Copy Markdown
Contributor

Addresses #8000.

The "Get data from XML" transform aborts the pipeline when a file cannot be parsed, instead of
routing the failure to the transform connected to its error hop. Reading the same document from a
field, or reading the file name from a field, behaves correctly — which is what makes the file path
look like an oversight rather than a design choice.

Cause

openNextFile() catches the parse failure and then unconditionally does this:

logError(...);
stopAll();
setErrors(1);
return false;

It never asks whether the transform has error handling configured, so stopAll() takes the whole
pipeline down. That produces the "Pipeline is killing the other transforms!" line in the report. The
in-fields path does ask — processPutRow checks getTransformMeta().isDoingErrorHandling() and
calls putError — which is exactly why the two paths behave differently.

Change

When error handling is enabled, the file is sent to the error stream and reading continues with the
next file. When it is not, the previous behaviour is untouched.

One wrinkle worth flagging for review. data.filenr is normally incremented before the document is
parsed, so recursing into openNextFile() moves on to the next file. But a failure raised earlier
— resolving the file, reading its size, its attributes — leaves the pointer untouched, and recursing
would retry the same file forever. The change records the pointer on entry and steps over the file
explicitly if it has not advanced.

openNextFile() now declares HopTransformException, because putError throws it. Every caller
already propagates HopException, so this does not ripple.

Tests

testErrorHandlingContinuesOnBadXmlFile is the file-based counterpart to the existing
testErrorHandlingContinuesOnBadXml: a temporary folder holding a good file, an unparseable one and
another good file, with an error hop attached.

  • both readable files are still read — 2 rows from the first, 1 from the third
  • the unreadable file yields exactly one error row
  • the pipeline reports no errors

Reverting the production change fails that test with transform should not report errors ==> expected: <0> but was: <1>, which is the behaviour described in the issue.

Verification

  • mvn -pl plugins/transforms/xml -Pskip-uitest test — 154 tests, 0 failures, 0 errors
  • mvn spotless:check and mvn apache-rat:check pass on the module

Get data from XML aborted the whole pipeline when a file could not be
parsed. openNextFile() caught the failure, called stopAll() and
setErrors(1) unconditionally, without ever asking whether the transform
has an error hop -- so an invalid document killed the pipeline instead of
being diverted, while the same document read from a field was handled
correctly.

When error handling is enabled, send the file to the error stream and
carry on with the next one, matching what processPutRow already does for
the in-fields path. The file pointer is normally advanced before the
document is parsed, but a failure raised earlier -- resolving the file,
reading its size or attributes -- leaves it untouched, so step over the
file explicitly in that case rather than retrying it forever.

openNextFile() now declares HopTransformException because putError()
throws it; every caller already propagates HopException.

Adds a file-based counterpart to testErrorHandlingContinuesOnBadXml: a
good file, an unparseable one and another good file. Both good files are
still read and the bad one produces a single error row. Reverting the
change fails the test with one reported error, which is the behaviour in
the report.
@hansva
hansva merged commit 8ea6adf into apache:main Aug 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants