Skip to content

Error: TypeError: Cannot read properties of undefined (reading 'split') when <failure> element has no value #239

@akomakom

Description

@akomakom

I am generating junit xml using golang and github.com/jstemmer/go-junit-report/v2@latest. Sometimes, on failure, it produces XML with an empty failure element. This produces a parse error:

Run dorny/test-reporter@v1
Action was triggered by pull_request: using SHA from head of source branch
...
Using test report parser 'java-junit'
Creating test report XXXX
  Processing test results for check run XXXX
  Creating check run XXXX
  Creating report summary
  Generating check run summary
Error: TypeError: Cannot read properties of undefined (reading 'split')

Sample XML:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="1">
    <testsuite name="my.company.com/suite/e2e/node_scale" tests="1" failures="1" errors="0" id="9"
               hostname="some-hostname.com" time="341.455" timestamp="2023-03-17T21:23:52Z">
        <testcase name="TestNodeScale" classname="my.company.com/e2e/node_scale" time="341.340">
            <failure message="Failed"></failure>
        </testcase>
    </testsuite>
</testsuites>

Adding a value, eg <failure message="Failed">bla</failure resolves this issue. I do not know if empty element is valid in junit format. If it is not valid, then I should open an issue with github.com/jstemmer/go-junit-report.

My action:

      - name: Publish Test Report
        uses: dorny/test-reporter@v1
        if: success() || failure()
        with:
          name: Junit Publish Test
          path: junit-sample.xml
          reporter: java-junit

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions