sbt-github-packages icon indicating copy to clipboard operation
sbt-github-packages copied to clipboard

Getting a broken pipe on initial publish command

Open halvorgb opened this issue 6 years ago • 11 comments

Testing your plugin, it looks promising. Although I had to use explicit credentials to get it to work :)

The first time I run publisher/publish for my (private) project I get an exception ([error] java.net.SocketException: Broken pipe (Write failed)). Although a package does get uploaded (I haven't yet tested if uploaded package works).

If I repeat the command I get a java.io.IOException: PUT operation to URL https://maven.pkg.github.com/<snip> failed with status code 422: Unprocessable Entity - which makes sense if it was already uploaded.

halvorgb avatar Dec 09 '19 09:12 halvorgb

Here's the stacktrace for the Broken Pipe, I can't gleam much useful data out of this.

[error] java.net.SocketException: Broken pipe (Write failed)
[error] 	at java.net.SocketOutputStream.socketWrite0(Native Method)
[error] 	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
[error] 	at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
[error] 	at sun.security.ssl.OutputRecord.writeBuffer(OutputRecord.java:431)
[error] 	at sun.security.ssl.OutputRecord.write(OutputRecord.java:417)
[error] 	at sun.security.ssl.SSLSocketImpl.writeRecordInternal(SSLSocketImpl.java:886)
[error] 	at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:857)
[error] 	at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
[error] 	at okio.Okio$1.write(Okio.java:78)
[error] 	at okio.AsyncTimeout$1.write(AsyncTimeout.java:179)
[error] 	at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:171)
[error] 	at okio.RealBufferedSink.write(RealBufferedSink.java:41)
[error] 	at okhttp3.internal.http1.Http1Codec$FixedLengthSink.write(Http1Codec.java:286)
[error] 	at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:171)
[error] 	at okio.RealBufferedSink.writeAll(RealBufferedSink.java:99)
[error] 	at okhttp3.RequestBody$3.writeTo(RequestBody.java:118)
[error] 	at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:62)
[error] 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error] 	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
[error] 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error] 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
[error] 	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
[error] 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error] 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
[error] 	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
[error] 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error] 	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
[error] 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
[error] 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
[error] 	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
[error] 	at okhttp3.RealCall.execute(RealCall.java:69)
[error] 	at sbt.internal.librarymanagement.ivyint.GigahorseUrlHandler.upload(GigahorseUrlHandler.scala:186)
[error] 	at org.apache.ivy.util.url.URLHandlerDispatcher.upload(URLHandlerDispatcher.java:82)
[error] 	at org.apache.ivy.util.FileUtil.copy(FileUtil.java:150)
[error] 	at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:84)
[error] 	at sbt.internal.librarymanagement.ConvertResolver$LocalIfFileRepo.put(ConvertResolver.scala:366)
[error] 	at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
[error] 	at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put(ConvertResolver.scala:118)
[error] 	at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put$(ConvertResolver.scala:105)
[error] 	at sbt.internal.librarymanagement.ConvertResolver$$anonfun$defaultConvert$lzycompute$1$PluginCapableResolver$1.put(ConvertResolver.scala:165)
[error] 	at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)
[error] 	at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$5(IvyActions.scala:497)
[error] 	at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$5$adapted(IvyActions.scala:496)
[error] 	at scala.collection.TraversableLike$WithFilter.$anonfun$foreach$1(TraversableLike.scala:788)
[error] 	at scala.collection.Iterator.foreach(Iterator.scala:937)
[error] 	at scala.collection.Iterator.foreach$(Iterator.scala:937)
[error] 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
[error] 	at scala.collection.IterableLike.foreach(IterableLike.scala:70)
[error] 	at scala.collection.IterableLike.foreach$(IterableLike.scala:69)
[error] 	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
[error] 	at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:787)
[error] 	at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:496)
[error] 	at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$3(IvyActions.scala:144)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] 	at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:157)
[error] 	at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:151)
[error] 	at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1(IvyActions.scala:144)
[error] 	at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1$adapted(IvyActions.scala:134)
[error] 	at sbt.internal.librarymanagement.IvySbt$Module.$anonfun$withModule$1(Ivy.scala:239)
[error] 	at sbt.internal.librarymanagement.IvySbt.$anonfun$withIvy$1(Ivy.scala:204)
[error] 	at sbt.internal.librarymanagement.IvySbt.sbt$internal$librarymanagement$IvySbt$$action$1(Ivy.scala:70)
[error] 	at sbt.internal.librarymanagement.IvySbt$$anon$3.call(Ivy.scala:77)
[error] 	at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:95)
[error] 	at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:80)
[error] 	at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:99)
[error] 	at xsbt.boot.Using$.withResource(Using.scala:10)
[error] 	at xsbt.boot.Using$.apply(Using.scala:9)
[error] 	at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:60)
[error] 	at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:50)
[error] 	at xsbt.boot.Locks$.apply0(Locks.scala:31)
[error] 	at xsbt.boot.Locks$.apply(Locks.scala:28)
[error] 	at sbt.internal.librarymanagement.IvySbt.withDefaultLogger(Ivy.scala:77)
[error] 	at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:199)
[error] 	at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:196)
[error] 	at sbt.internal.librarymanagement.IvySbt$Module.withModule(Ivy.scala:238)
[error] 	at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:134)
[error] 	at sbt.Classpaths$.$anonfun$publishTask$4(Defaults.scala:2416)
[error] 	at sbt.Classpaths$.$anonfun$publishTask$4$adapted(Defaults.scala:2416)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error] 	at sbt.std.Transform$$anon$4.work(System.scala:67)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] 	at sbt.Execute.work(Execute.scala:278)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] 	at java.lang.Thread.run(Thread.java:748)
[error] (publish) java.net.SocketException: Broken pipe (Write failed)

halvorgb avatar Dec 09 '19 09:12 halvorgb

Interesting! What was the version in question? The second broken pipe is definitely expected; I wish there were a nicer way I could detect this and tell users "don't publish duplicate versions". The first one though is unexpected. Could it have been a transient network failure? Is this a multi-project build?

djspiewak avatar Dec 09 '19 15:12 djspiewak

Oh also, can you open a separate bug for the credentials issue?

djspiewak avatar Dec 09 '19 15:12 djspiewak

Here is a reproduction of the initial broken pipe error:

https://github.com/halvorgb/spgreproduction

to test:

GITHUB_USER=user GITHUB_TOKEN=token sbt publisher/publish

halvorgb avatar Dec 16 '19 14:12 halvorgb

I'm not confident that the credentials issue isn't a user error from my side, supplying both from the environment (as above) works very well for me though.

halvorgb avatar Dec 16 '19 14:12 halvorgb

I encountered the same exact sequence of errors. The authentication error in the first step causes Github to write a .pom file with the following contents:

AccessDeniedRequest has expired3002020-03-13T14:28:43Z2020-03-13T14:44:<redacted>
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Request has expired</Message>
<X-Amz-Expires>300</X-Amz-Expires>
<Expires>2020-03-13T14:28:43Z</Expires>
<ServerTime>2020-03-13T14:44:17Z</ServerTime>
<RequestId>B4ADAB7B0C51F0FD</RequestId>
<HostId>
1pir2xrcW4mYwlC2M3FUVAUBHdr6fVCtaPTZq19h1s2gyCT6xN+JC+JmCtsjNKAYnRdDMg/1F7o=
</HostId>
<HostId>...</HostId>
</Error>
<Error>...</Error>

The server time seems to be off causing an expiration of the request and the error.

Subsequent calls then raise an exception because a .pom file is present, even though it's just the above error message stored in the .pom file.

After 5 or 6 attempts it suddenly works.

tverbeiren avatar Mar 13 '20 15:03 tverbeiren

@tverbeiren Are you user your local time is correctly sync'd? I've published (conservatively) thousands of times to Packages over the past month and haven't seen this error. Most of the time though, I've been publishing from GitHub Actions, though I've also done a fair amount of local publication.

djspiewak avatar Mar 13 '20 19:03 djspiewak

It's the first thing I checked, yes. It effectively looked as if the github side used the wrong timestamp so the cause may be on their side.

BTW: Having to publish a couple of time in itself is not a big deal, but in combination with the lack of proper support - via the web interface - for deleting stuff from packages, versioning quickly becomes a pain. Do you have a suggested solution for removing a specific version from the packages list?

tverbeiren avatar Mar 14 '20 09:03 tverbeiren

@tverbeiren You can remove packages in the webinterface: image When you click "Manage versions" you should be able to delete versions. At least this should work for private repositories. However for public ones I think this is not possible.

mkurz avatar Mar 14 '20 12:03 mkurz

@mkurz I guess I don't see the option in the web interface because it's a public repo then...

tverbeiren avatar Mar 14 '20 14:03 tverbeiren

It's the first thing I checked, yes. It effectively looked as if the github side used the wrong timestamp so the cause may be on their side.

This wouldn't surprise me. I've also noticed a lot of transient failures with GitHub Packages. It would be relatively generous to call it "in beta" at this point.

BTW: Having to publish a couple of time in itself is not a big deal, but in combination with the lack of proper support - via the web interface - for deleting stuff from packages, versioning quickly becomes a pain. Do you have a suggested solution for removing a specific version from the packages list?

Yeah that part is a pain with public repos. It's fine with private ones, though there are still problems (e.g. artifact names become "sticky" to the first repository to which they are published, and even if you delete the published artifacts, you still can't move them to a different repo). I see why they don't allow deletion on public repos (and I do honestly support it), but it's a pain to be sure when you're trying to get stuff initially set up.

I did a lot of work with snapshots. Also my company vomits out releases on our internal repos, so early experiments got buried quickly. There isn't a good solution for getting rid of the partially-broken stuff though. :-(

djspiewak avatar Mar 14 '20 18:03 djspiewak