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

sbom upload fails with "Input length = 1" after Jenkins upgrade #223

Closed
joerg-nothnagel opened this issue Feb 9, 2024 · 1 comment
Closed
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@joerg-nothnagel
Copy link

Describe the bug

After upgrading Jenkins Controller from 2.332.1 to 2.426.3 sbom upload fails with this error.

[2024-02-07T12:30:20.997Z] [DependencyTrack] An error occurred processing artifact "bom.xml". Error was: Input length = 1

The bom in question is a properly encoded utf8 document containing an "umlaut" "ö" encoded as C3B6
Findings:

  • file.encoding on the agent as reported by Jenkins controller: ANSI_X3.4-1968
  • commit e5b9bf8 on master branch already contains a fix (not sure if the actual upload would succeed, though)

Environment

  • Plugin Version: 4.3.0 / 4.3.1
  • Jenkins Version: container jenkins/jenkins:2.426.3-lts-jdk11
  • Java Version for Jenkins:
  • Type of Jenkins Job: declarative pipeline
  • Dependency-Track Version: 4.8.2

To Reproduce

Steps to reproduce the behavior:

  • set file.encoding on the agent to ANSI_X3.4-1968 (e.g. by starting agent with -Dfile.encoding= ...)
    we extracted code from ApiClient.java and put it into our groovy helper library to reproduce
executor.echo("default charset:"+java.nio.charset.Charset.defaultCharset());
       final FilePath a = new FilePath(Jenkins.getInstance().getComputer(executor.NODE_NAME).getChannel(),artifact);
       // the code used by our plugin version:  fails without -Dfile.encoding=UTF-8
       //org.apache.commons.codec.binary.Base64.encodeBase64String(a.readToString().getBytes(StandardCharsets.UTF_8));
       // the code used on the master branch:  does not fail without -Dfile.encoding=UTF-8
       java.util.Base64.getEncoder().encodeToString(a.read().readAllBytes());

stack trace produced by above code (unfortunately, the plugin itself does not emit the stack trace)


Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to f36usd16
		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1787)
		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
		at hudson.remoting.Channel.call(Channel.java:1003)
		at hudson.FilePath.act(FilePath.java:1230)
		at hudson.FilePath.act(FilePath.java:1219)
		at hudson.FilePath.readToString(FilePath.java:2493)
		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
		at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
		at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
		at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
		at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
		at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
		at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
		at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
		at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
		at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:90)
		at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
		at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:78)
		at jdk.internal.reflect.GeneratedMethodAccessor156.invoke(Unknown Source)
		at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.base/java.lang.reflect.Method.invoke(Method.java:566)
		at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
		at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
		at com.cloudbees.groovy.cps.Next.step(Next.java:83)
		at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:177)
		at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:166)
		at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
		at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
		at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:166)
		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
		at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:420)
		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:95)
		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
		at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
		at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
		at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
		at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
		at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
		at jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51)
		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)
Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 0ac1403c-503e-450e-b5a7-4fc4f0664734
java.nio.charset.MalformedInputException: Input length = 1
	at java.base/java.lang.StringCoding.throwMalformed(StringCoding.java:707)
	at java.base/java.lang.StringCoding.throwMalformed(StringCoding.java:713)
	at java.base/java.lang.StringCoding.newStringNoRepl1(StringCoding.java:1040)
	at java.base/java.lang.StringCoding.newStringNoRepl(StringCoding.java:1015)
	at java.base/java.lang.System$2.newStringNoRepl(System.java:2214)
	at java.base/java.nio.file.Files.readString(Files.java:3287)
	at hudson.FilePath$ReadToString.invoke(FilePath.java:2501)
	at hudson.FilePath$ReadToString.invoke(FilePath.java:2496)
	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3616)
	at hudson.remoting.UserRequest.perform(UserRequest.java:211)
	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
	at hudson.remoting.Request$2.run(Request.java:377)
	at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
	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 hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:125)
	at java.base/java.lang.Thread.run(Thread.java:829)

our actual upload call:

dependencyTrackPublisher(
                    artifact: artifact,
                    autoCreateProjects: true,
                    dependencyTrackApiKey: executor.API_KEY,
                    projectName: this.projectArtifactId,
                    projectVersion: uploadVersion,
                    synchronous: false)

Expected behavior

sbom should upload correctly

Additional context

current workaround is to start the agent with -Dfile.encoding=UTF-8

@joerg-nothnagel joerg-nothnagel added the bug Something isn't working label Feb 9, 2024
@sephiroth-j
Copy link
Member

duplicate of #138

@sephiroth-j sephiroth-j closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2024
@sephiroth-j sephiroth-j added the duplicate This issue or pull request already exists label Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants