Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
akomakom opened this issue Mar 17, 2023 · 2 comments

Comments

@akomakom
Copy link

akomakom commented Mar 17, 2023

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
@ThorntonMatthewD
Copy link

ThorntonMatthewD commented Mar 30, 2023

I am experiencing this same issue, except with XML output from rspec_junit_formatter.

Run dorny/test-reporter@v1
Check runs will be created with SHA=XXX
> Listing all files tracked by git
Found 4538 files tracked by GitHub
Using test report parser 'java-junit'
> Creating test report Rspec Test Results
  Processing test results for check run Rspec Test Results
  Creating check run My Awesone Test
  Creating report summary
  Generating check run summary
  Creating annotations
Error: TypeError: Cannot read properties of undefined (reading 'split')

My failure does occur further along in, however, in the Creating annotations step. Since we've used the same reporter, it may be something to do with the parser which results in:

message: err.message ?? getFirstNonEmptyLine(err.details) ?? 'Test failed',

err.details === undefined

@YevheniiaSilbernagl
Copy link

I'm having a similar issue parsing junit report format from dependency-check/Dependency-Check_Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants