Unable to create snippet

Issue #62 resolved
Anton Stamenov [HC] created an issue

I just installed the plugin and hit a problem. I also cannot find how I can reset the OAuth token, I have few BitBucket accounts and I want to link to another one.

2019-01-13 11:43:58,789 [1219300]  ERROR - intellij.openapi.progress.Task - Error requesting 'create snippet' API endpoint 
com.atlassian.bitbucket.cloud.rest.BitbucketCloudRestClientException: Error requesting 'create snippet' API endpoint
    at com.atlassian.bitbucket.cloud.rest.common.ErrorsKt$mapErrors$3.invoke(errors.kt:22)
    at com.atlassian.bitbucket.cloud.rest.common.ErrorsKt.mapErrors(errors.kt:52)
    at com.atlassian.bitbucket.cloud.rest.common.ErrorsKt$mapErrors$1.invokeSuspend(errors.kt)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
    at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(PipelineContext.kt:211)
    at io.ktor.util.pipeline.SuspendFunctionGun.access$resumeRootWith(PipelineContext.kt:63)
    at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(PipelineContext.kt:114)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:45)
    at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(PipelineContext.kt:211)
    at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:186)
    at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(PipelineContext.kt:63)
    at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:137)
    at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:157)
    at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:24)
    at io.ktor.client.features.HttpSend$DefaultSender.execute(HttpSend.kt:86)
    at io.ktor.client.features.HttpSend$Feature$install$1.invokeSuspend(HttpSend.kt:58)
    at io.ktor.client.features.HttpSend$Feature$install$1.invoke(HttpSend.kt)
    at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:278)
    at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(PipelineContext.kt:63)
    at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:137)
    at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:157)
    at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:24)
    at io.ktor.client.HttpClient.execute(HttpClient.kt:151)
    at io.ktor.client.call.HttpClientCallKt.call(HttpClientCall.kt:80)
    at io.ktor.client.call.UtilsKt.call(utils.kt:16)
    at com.atlassian.bitbucket.cloud.rest.snippet.SnippetCreationApiImpl$save$$inlined$use$lambda$1.invokeSuspend(snippets.kt:95)
    at com.atlassian.bitbucket.cloud.rest.snippet.SnippetCreationApiImpl$save$$inlined$use$lambda$1.invoke(snippets.kt)
    at com.atlassian.bitbucket.cloud.rest.common.ErrorsKt.mapErrors(errors.kt:25)
    at com.atlassian.bitbucket.cloud.rest.common.ErrorsKt.mapErrors$default(errors.kt:18)
    at com.atlassian.bitbucket.cloud.rest.snippet.SnippetCreationApiImpl.save(snippets.kt:68)
    at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1$run$1$1$3.invokeSuspend(create-snippet.kt:74)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
    at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.kt:116)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:76)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:53)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
    at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1$run$1$1.invoke(create-snippet.kt:73)
    at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1$run$1$1.invoke(create-snippet.kt:48)
    at com.atlassian.bitbucket.linky.actions.authenticated.DefaultCloudAuthenticator$invoke$2.invoke(cloud-authentication.kt:33)
    at com.atlassian.bitbucket.linky.actions.authenticated.DefaultCloudAuthenticator.invoke(cloud-authentication.kt:37)
    at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1$run$1.invokeSuspend(create-snippet.kt:52)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
    at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.kt:116)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:76)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:53)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
    at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1.run(create-snippet.kt:51)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:727)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:582)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
    at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:403)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Request cannot be executed; I/O reactor status: STOPPED
    at org.apache.http.util.Asserts.check(Asserts.java:46)
    at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.ensureRunning(CloseableHttpAsyncClientBase.java:90)
    at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:123)
    at org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:68)
    at io.ktor.client.engine.apache.ApacheHttpRequestKt.sendRequest(ApacheHttpRequest.kt:56)
    at io.ktor.client.engine.apache.ApacheEngine.execute(ApacheEngine.kt:20)
    at io.ktor.client.HttpClient$$special$$inlined$apply$lambda$1.invokeSuspend(HttpClient.kt:86)
    at io.ktor.client.HttpClient$$special$$inlined$apply$lambda$1.invoke(HttpClient.kt)
    at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:278)
    ... 56 more
2019-01-13 11:43:58,792 [1219303]  ERROR - intellij.openapi.progress.Task - PyCharm 2018.3.3  Build #PY-183.5153.39 
2019-01-13 11:43:58,792 [1219303]  ERROR - intellij.openapi.progress.Task - JDK: 1.8.0_152-release; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o 
2019-01-13 11:43:58,792 [1219303]  ERROR - intellij.openapi.progress.Task - OS: Mac OS X 
2019-01-13 11:43:58,793 [1219304]  ERROR - intellij.openapi.progress.Task - Plugin to blame: Bitbucket Linky version: 6.2 
2019-01-13 11:43:58,793 [1219304]  ERROR - intellij.openapi.progress.Task - Last Action: Bitbucket.CreateSnippet 

Comments (8)

  1. Daniil Penkin staff

    Hello @lidow,

    Thanks for reporting this!

    I also faced this bug just before the weekend and have already prepared a fix for the problem which causes it, I plan to release a version within a day or two. I'll let you know once it's out.

    Cheers, Daniil

  2. Daniil Penkin staff

    I also cannot find how I can reset the OAuth token, I have few BitBucket accounts and I want to link to another one.

    Sorry, I read this but forgot to answer in my comment above. I also have seen your suggestion about per-project OAuth token, and I'll reply on that there, so here I'll only tell how to reset OAuth with the current implementation.

    The right way to do this at the moment is to go to your profile settings in Bitbucket, select OAuth and click on Revoke for Bitbucket Linky in OAuth integrated applications list. The URL of this screen for your current user is this: https://bitbucket.org/account/user/lidow/api

    Next time you invoke an action requiring authentication with Bitbucket from PyCharm Linky will try to use the old credentials and get 401 back, which will trigger restart of the OAuth dance – Linky will ask you to set it up again.

    Cheers, Daniil

  3. Anton Stamenov [HC] reporter

    Hello Daniil,

    I've revoked OAuth from first account and then restart PyCharm and try to submit new snippet. I expected to be asked to grant new OAuth token, but I got this error:

    com.atlassian.bitbucket.cloud.rest.oauth.OAuthNotConfiguredException: OAuth is not configured
        at com.atlassian.bitbucket.cloud.rest.oauth.BitbucketCloudOAuthImpl.requestAuthTokens(rest.kt:52)
        at com.atlassian.bitbucket.cloud.rest.oauth.BitbucketCloudOAuthImpl.access$requestAuthTokens(rest.kt:13)
        at com.atlassian.bitbucket.cloud.rest.oauth.BitbucketCloudOAuthImpl$refreshOAuthTokens$1.call(rest.kt:28)
        at com.atlassian.bitbucket.cloud.rest.oauth.BitbucketCloudOAuthImpl$refreshOAuthTokens$1.call(rest.kt:13)
        at rx.internal.operators.SingleFromCallable.call(SingleFromCallable.java:41)
        at rx.internal.operators.SingleFromCallable.call(SingleFromCallable.java:29)
        at rx.Single.subscribe(Single.java:1979)
        at rx.singles.BlockingSingle.value(BlockingSingle.java:69)
        at com.atlassian.bitbucket.cloud.rest.oauth.OAuthAuthenticator.refreshTokens(authenticate.kt:66)
        at com.atlassian.bitbucket.cloud.rest.oauth.OAuthAuthenticator.access$refreshTokens(authenticate.kt:50)
        at com.atlassian.bitbucket.cloud.rest.oauth.OAuthAuthenticator$authenticate$1.invoke(authenticate.kt:60)
        at com.atlassian.bitbucket.cloud.rest.oauth.OAuthAuthenticator$authenticate$1.invoke(authenticate.kt:50)
        at com.atlassian.bitbucket.cloud.rest.oauth.OAuthTokenHolderImpl.refreshTokens(authenticate.kt:32)
        at com.atlassian.bitbucket.cloud.rest.oauth.OAuthAuthenticator.authenticate(authenticate.kt:60)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.followUpRequest(RetryAndFollowUpInterceptor.java:289)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:157)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at com.atlassian.bitbucket.cloud.rest.oauth.OAuthInterceptor.intercept(authenticate.kt:47)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:212)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
        at okhttp3.RealCall.execute(RealCall.java:77)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:180)
        at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:40)
        at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:24)
        at retrofit2.adapter.rxjava.BodyOnSubscribe.call(BodyOnSubscribe.java:36)
        at retrofit2.adapter.rxjava.BodyOnSubscribe.call(BodyOnSubscribe.java:28)
        at rx.Observable.unsafeSubscribe(Observable.java:10256)
        at rx.internal.operators.OnSubscribeSingle.call(OnSubscribeSingle.java:81)
        at rx.internal.operators.OnSubscribeSingle.call(OnSubscribeSingle.java:27)
        at rx.Single.subscribe(Single.java:1979)
        at rx.internal.operators.SingleOnSubscribeMap.call(SingleOnSubscribeMap.java:45)
        at rx.internal.operators.SingleOnSubscribeMap.call(SingleOnSubscribeMap.java:30)
        at rx.Single.subscribe(Single.java:1979)
        at rx.internal.operators.SingleDoAfterTerminate.call(SingleDoAfterTerminate.java:42)
        at rx.internal.operators.SingleDoAfterTerminate.call(SingleDoAfterTerminate.java:28)
        at rx.internal.operators.SingleToObservable.call(SingleToObservable.java:39)
        at rx.internal.operators.SingleToObservable.call(SingleToObservable.java:27)
        at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
        at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
        at rx.Observable.unsafeSubscribe(Observable.java:10256)
        at rx.internal.operators.OnSubscribeSingle.call(OnSubscribeSingle.java:81)
        at rx.internal.operators.OnSubscribeSingle.call(OnSubscribeSingle.java:27)
        at rx.Single.subscribe(Single.java:1979)
        at kotlinx.coroutines.experimental.rx1.RxAwaitKt.await(RxAwait.kt:41)
        at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1$run$1$1$3.doResume(create-snippet.kt:71)
        at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
        at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:149)
        at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
        at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:140)
        at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:70)
        at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:46)
        at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
        at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
        at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1$run$1$1.invoke(create-snippet.kt:70)
        at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1$run$1$1.invoke(create-snippet.kt:47)
        at com.atlassian.bitbucket.linky.actions.authenticated.DefaultCloudAuthenticator$invoke$2.invoke(cloud-authentication.kt:30)
        at com.atlassian.bitbucket.linky.actions.authenticated.DefaultCloudAuthenticator.invoke(cloud-authentication.kt:34)
        at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1$run$1.doResume(create-snippet.kt:51)
        at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
        at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:149)
        at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
        at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:140)
        at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:70)
        at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:46)
        at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
        at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
        at com.atlassian.bitbucket.linky.actions.snippet.CreateSnippetAction$actionPerformed$1.run(create-snippet.kt:50)
        at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:727)
        at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
        at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:582)
        at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
        at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
        at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:403)
        at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    
  4. Daniil Penkin staff

    Oh right, in 5.2 you'll also need to delete locally saved tokens. From the log above I see you're using Mac OS, so assuming you haven't changed preferred password storage in PyCharm you'd need to delete the following records from your default Keychain:

    IntelliJ Platform Linky — refresh token IntelliJ Platform Linky — access token

    You don't need to shut down PyCharm while you do that: tokens are retrieved on each call.

    FYI Today I'm going to release an update which fixes snippets creation and a couple of other issues in the latest releases. Starting with version 6 just revoking the token on Bitbucket side would be enough.

    Sorry for the inconvenience.

    Cheers, Daniil

  5. Anton Stamenov [HC] reporter

    Thank you Daniil,

    Everything worked on v5.2, I've checked URL copy/open + snippets. I'll follow the plugin and I will try again with next v6.x version. Current v6.2 is not working for snippets, but you already confirmed that there is a fix within upcoming update.

  6. Daniil Penkin staff

    Hi @antonstamenov,

    Just a heads up, I released version 6.3 which fixes the issue with snippets.

    Cheers, Daniil

  7. Log in to comment