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

Illegal XML characters in test output not handled correctly #580

Open
bsfarrell opened this issue Oct 16, 2023 · 0 comments
Open

Illegal XML characters in test output not handled correctly #580

bsfarrell opened this issue Oct 16, 2023 · 0 comments
Labels

Comments

@bsfarrell
Copy link

Jenkins and plugins versions report

Environment
Jenkins: 2.414.2
OS: Linux - 5.4.0-162-generic
Java: 11.0.16.1 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
ansicolor:1.0.4
ant:497.v94e7d9fffa_b_9
antisamy-markup-formatter:162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api:4.5.14-208.v438351942757
apache-httpcomponents-client-5-api:5.2.1-1.0
artifactory:3.18.9
authentication-tokens:1.53.v1c90fd9191a_b_
authorize-project:1.7.1
badge:1.9.1
basic-branch-build-strategies:81.v05e333931c7d
bootstrap5-api:5.3.2-1
bouncycastle-api:2.29
branch-api:2.1128.v717130d4f816
build-failure-analyzer:2.4.1
build-keeper-plugin:19.va_df8a_2c65123
build-name-setter:2.3.0
caffeine-api:3.1.8-133.v17b_1ff2e0599
checks-api:2.0.2
cloud-stats:320.v96b_65297a_4b_b_
cloudbees-disk-usage-simple:182.v62ca_0c992a_f3
cloudbees-folder:6.848.ve3b_fd7839a_81
code-coverage-api:4.7.0
command-launcher:107.v773860566e2e
commons-httpclient3-api:3.1-3
commons-lang3-api:3.13.0-62.v7d18e55f51e2
commons-text-api:1.10.0-78.v3e7b_ea_d5a_fe1
conditional-buildstep:1.4.3
config-file-provider:959.vcff671a_4518b_
configuration-as-code:1700.v6f448841296e
copyartifact:722.v0662a_9b_e22a_c
credentials:1271.v54b_1c2c6388a_
credentials-binding:636.v55f1275c7b_27
cvs:2.19.1
dark-theme:336.v02165cd8c2ee
data-tables-api:1.13.6-4
display-url-api:2.3.9
docker-commons:439.va_3cb_0a_6a_fb_29
docker-java-api:3.3.1-79.v20b_53427e041
docker-plugin:1.5
docker-workflow:572.v950f58993843
durable-task:523.va_a_22cf15d5e0
echarts-api:5.4.0-6
email-ext:2.101
extended-read-permission:53.v6499940139e5
external-monitor-job:215.v2e88e894db_f8
favorite:2.4.3
flaky-test-handler:1.2.3
font-awesome-api:6.4.2-1
forensics-api:2.3.0
generic-webhook-trigger:1.87.0
ghprb:1.42.2
git:5.2.0
git-client:4.5.0
git-server:99.va_0826a_b_cdfa_d
github:1.37.3
github-api:1.314-431.v78d72a_3fe4c3
github-branch-source:1741.va_3028eb_9fd21
github-checks:554.vb_ee03a_000f65
github-pr-coverage-status:2.2.0
google-oauth-plugin:1.0.11
gradle:2.8.2
groovy:453.vcdb_a_c5c99890
groovy-postbuild:2.5
handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953
htmlpublisher:1.32
http_request:1.18
icon-shim:3.0.0
instance-identity:173.va_37c494ec4e5
ionicons-api:56.v1b_1c8c49374e
ivy:2.5
jackson2-api:2.15.2-350.v0c2f3f8fc595
jacoco:3.3.4
jakarta-activation-api:2.0.1-3
jakarta-mail-api:2.0.1-3
javadoc:243.vb_b_503b_b_45537
javax-activation-api:1.2.0-6
javax-mail-api:1.6.2-9
jaxb:2.3.8-1
jdk-tool:73.vddf737284550
jenkins-design-language:1.27.7
jersey2-api:2.40-1
jira:3.11
jjwt-api:0.11.5-77.v646c772fddb_0
jmh-report:0.9.0
jnr-posix-api:3.1.17-1
job-dsl:1.85
jobConfigHistory:1229.v3039470161a_d
jquery:1.12.4-1
jquery3-api:3.7.1-1
jsch:0.2.8-65.v052c39de79b_2
junit:1240.vf9529b_881428
kubernetes:4029.v5712230ccb_f8
kubernetes-client-api:6.8.1-224.vd388fca_4db_3b_
kubernetes-credentials:0.11
label-linked-jobs:6.0.1
ldap:701.vf8619de9160a_
lockable-resources:1185.v0c528656ce04
logfilesizechecker:1.5
login-theme:78.vc3f59c35b_69d
mailer:463.vedf8358e006b_
mapdb-api:1.0.9-28.vf251ce40855d
material-theme:0.5.2-rc100.6121925fe229
matrix-auth:3.2.1
matrix-project:808.v5a_b_5f56d6966
maven-plugin:3.23
mercurial:1260.vdfb_723cdcc81
metrics:4.2.18-442.v02e107157925
mina-sshd-api-common:2.10.0-69.v28e3e36d18eb_
mina-sshd-api-core:2.10.0-69.v28e3e36d18eb_
monitoring:1.95.0
next-build-number:1.8
nodelabelparameter:1.12.0
oauth-credentials:0.646.v02b_66dc03d2e
okhttp-api:4.11.0-157.v6852a_a_fa_ec11
pam-auth:1.10
parameterized-trigger:2.46
pipeline-build-step:505.v5f0844d8d126
pipeline-github:2.8-155.8eab375ac9f8
pipeline-githubnotify-step:49.vf37bf92d2bc8
pipeline-graph-analysis:202.va_d268e64deb_3
pipeline-groovy-lib:689.veec561a_dee13
pipeline-input-step:477.v339683a_8d55e
pipeline-milestone-step:111.v449306f708b_7
pipeline-model-api:2.2144.v077a_d1928a_40
pipeline-model-declarative-agent:1.1.1
pipeline-model-definition:2.2144.v077a_d1928a_40
pipeline-model-extensions:2.2144.v077a_d1928a_40
pipeline-rest-api:2.33
pipeline-stage-step:305.ve96d0205c1c6
pipeline-stage-tags-metadata:2.2144.v077a_d1928a_40
pipeline-stage-view:2.33
pipeline-utility-steps:2.16.0
plain-credentials:143.v1b_df8b_d3b_e48
plugin-util-api:3.3.0
prism-api:1.29.0-7
pubsub-light:1.17
purge-build-queue-plugin:88.v23b_97b_f2c7a_d
rebuild:327.v67ca_b_b_6cd42e
resource-disposer:0.23
rich-text-publisher-plugin:1.5
run-condition:1.7
saferestart:0.7
saml:4.429.v9a_781a_61f1da_
scm-api:676.v886669a_199a_a_
script-security:1275.v23895f409fb_d
sidebar-link:2.2.4
simple-theme-plugin:160.vb_76454b_67900
slack:684.v833089650554
snakeyaml-api:2.2-111.vc6598e30cc65
sonar:2.15
sse-gateway:1.26
ssh:2.6.1
ssh-agent:333.v878b_53c89511
ssh-credentials:308.ve4497b_ccd8f4
ssh-slaves:2.916.vd17b_43357ce4
ssh-steps:2.0.65.vd26b_5b_9b_de4d
sshd:3.312.v1c601b_c83b_0e
startup-trigger-plugin:2.9.3
structs:325.vcb_307d2a_2782
subversion:2.17.3
support-core:1356.vd0f980edfa_46
theme-manager:211.vef2a_42c645a_b_
timestamper:1.26
token-macro:384.vf35b_f26814ec
trilead-api:2.84.v72119de229b_7
variant:60.v7290fc0eb_b_cd
workflow-aggregator:596.v8c21c963d92d
workflow-api:1281.vca_5fddb_3fceb_
workflow-basic-steps:1042.ve7b_140c4a_e0c
workflow-cps:3791.va_c0338ea_b_59c
workflow-durable-task-step:1289.v4d3e7b_01546b_
workflow-job:1346.v180a_63f40267
workflow-multibranch:756.v891d88f2cd46
workflow-scm-step:415.v434365564324
workflow-step-api:639.v6eca_cd8c04a_a_
workflow-support:865.v43e78cc44e0d
ws-cleanup:0.45

What Operating System are you using (both controller, and any agents involved in the problem)?

Ubuntu Linux 20.04 on controller and agents

Reproduction steps

I created a simple pipeline script to reproduce the issue:

node {
    writeFile file: 'TEST-MyTest.xml', text: '''<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="MyTest" time="1" tests="1" errors="0" skipped="0" failures="0">
  <properties/>
  <testcase name="test" classname="MyTest" time="1"/>
</testsuite>'''
    // 77+/Cg== is 0xFFFF base64-encoded.
    sh 'echo "77+/Cg==" | base64 -d > MyTest-output.txt'
    
    junit 'TEST-MyTest.xml'
    archiveArtifacts 'MyTest-output.txt'
}

Expected Results

I would expect a successful build with a JUnit result containing one successful test. The test stdout should be displayed, although I don't particularly care how the unicode character is displayed/escaped.

Actual Results

Stack trace logged in the job console output

Console Output
Recording test results
FATAL: Failed to save the JUnit test result
java.io.IOException: java.lang.RuntimeException: Failed to serialize hudson.tasks.junit.TestResult#suites for class hudson.tasks.junit.TestResult
	at hudson.XmlFile.write(XmlFile.java:220)
	at hudson.tasks.junit.TestResultAction.setResult(TestResultAction.java:124)
	at hudson.tasks.junit.TestResultAction.<init>(TestResultAction.java:90)
	at hudson.tasks.junit.JUnitResultArchiver.parseAndSummarize(JUnitResultArchiver.java:268)
	at hudson.tasks.junit.pipeline.JUnitResultsStepExecution.run(JUnitResultsStepExecution.java:63)
	at hudson.tasks.junit.pipeline.JUnitResultsStepExecution.run(JUnitResultsStepExecution.java:29)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.RuntimeException: Failed to serialize hudson.tasks.junit.TestResult#suites for class hudson.tasks.junit.TestResult
	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:274)
	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:241)
	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:174)
	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:226)
	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:163)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:44)
	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:83)
	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1303)
	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1292)
	at com.thoughtworks.xstream.XStream.toXML(XStream.java:1265)
	at hudson.XmlFile.write(XmlFile.java:213)
	... 11 more
Caused by: java.lang.RuntimeException: Failed to serialize hudson.tasks.junit.SuiteResult#stdout for class hudson.tasks.junit.SuiteResult
	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:274)
	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:241)
	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:174)
	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:226)
	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:163)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:44)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:87)
	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeBareItem(AbstractCollectionConverter.java:94)
	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:66)
	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeCompleteItem(AbstractCollectionConverter.java:81)
	at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:75)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83)
	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:283)
	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:270)
	... 24 more
Caused by: com.thoughtworks.xstream.io.StreamException: Invalid character 0xffff in XML stream
	at hudson.util.PrettyPrintWriter.lambda$writeText$0(PrettyPrintWriter.java:269)
	at java.base/java.lang.StringUTF16$CodePointsSpliterator.advance(StringUTF16.java:1165)
	at java.base/java.lang.StringUTF16$CodePointsSpliterator.forEachRemaining(StringUTF16.java:1137)
	at java.base/java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:593)
	at hudson.util.PrettyPrintWriter.writeText(PrettyPrintWriter.java:214)
	at hudson.util.PrettyPrintWriter.writeText(PrettyPrintWriter.java:210)
	at hudson.util.PrettyPrintWriter.setValue(PrettyPrintWriter.java:192)
	at com.thoughtworks.xstream.io.WriterWrapper.setValue(WriterWrapper.java:45)
	at com.thoughtworks.xstream.converters.SingleValueConverterWrapper.marshal(SingleValueConverterWrapper.java:45)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:50)
	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83)
	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:283)
	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:270)
	... 41 more

Initially, the JUnit results in Jenkins will look correct, but since the result weren't persisted to disk, they'll be lost once the in-memory results are discarded.

Anything else?

No response

@bsfarrell bsfarrell added the bug label Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
@bsfarrell and others