- edited description
Bitbucket Cloud : failed to create a snippet
Ubuntu 22
PyCharm 2022.3.2 (Professional Edition)
Build #PY-223.8617.48, built on January 24, 2023
Bitbucket Linky version 2022.1.223
Steps:
- Right click in Pycharm
- Choose “Create snippet” in context menu
- Fill the name to the snippet creation form, press create button
- Got the error
Failed to create a snippet
com.atlassian.bitbucket.linky.rest.BadResponseCodeException: Got response with 400 (Bad Request) for create snippet endpoint
at com.atlassian.bitbucket.linky.rest.ExceptionsKt.mapException(exceptions.kt:49)
at com.atlassian.bitbucket.linky.rest.ExceptionsKt.mapException$default(exceptions.kt:38)
at com.atlassian.bitbucket.linky.rest.cloud.SnippetsApiImpl$create$3.invoke(SnippetsApiImpl.kt:51)
at com.atlassian.bitbucket.linky.rest.cloud.SnippetsApiImpl$create$3.invoke(SnippetsApiImpl.kt:48)
at com.github.kittinunf.fuel.core.DeserializableKt$response$2.invoke(Deserializable.kt:108)
at com.github.kittinunf.fuel.core.DeserializableKt$response$2.invoke(Deserializable.kt)
at com.github.kittinunf.fuel.core.DeserializableKt$response$asyncRequest$2$1.invoke(Deserializable.kt:217)
at com.github.kittinunf.fuel.core.DeserializableKt$response$asyncRequest$2$1.invoke(Deserializable.kt)
at com.github.kittinunf.fuel.core.RequestExecutionOptionsKt$sam$java_lang_Runnable$0.run(RequestExecutionOptions.kt)
at com.github.kittinunf.fuel.core.DefaultEnvironment$callbackExecutor$1.execute(Environment.kt:16)
at com.github.kittinunf.fuel.core.RequestExecutionOptions.callback(RequestExecutionOptions.kt:44)
at com.github.kittinunf.fuel.core.DeserializableKt$response$asyncRequest$2.invoke(Deserializable.kt:216)
at com.github.kittinunf.fuel.core.DeserializableKt$response$asyncRequest$2.invoke(Deserializable.kt)
at com.github.kittinunf.fuel.core.requests.RequestTaskCallbacks.call(RequestTaskCallbacks.kt:30)
at com.github.kittinunf.fuel.core.requests.RequestTaskCallbacks.call(RequestTaskCallbacks.kt:20)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Comments (6)
-
reporter -
reporter Worked fine before.
-
staff Hello @Peter Volkov ,
Thanks for reporting the issue, definitely something for me to fix.
Sadly I wasn’t able to reproduce it so far. I tried creating a snippet from an entire file and from selected text but never got such error.
If you are able to reproduce, could you please collect some debug logging?
- Go to
Help -> Diagnostic Tools -> Debug Log Settings...
- In the dialog that will appear add
BitbucketLinky
and click OK - Reopen the affected project or simply restart your IDE
- Reproduce the bug
- Go to
Help -> Show Log in Finder
(Help -> Show Log in Explorer
on Windows) - Attach revealed
idea.log
to the issue, or better filter out just the lines containingBitbucketLinky
I’m specifically interested in the response from Bitbucket: it might contain some hint on why the request is considered invalid.
Cheers,
Daniil - Go to
-
reporter Sorry, Daniil. I guess this is my fault and misinterpretation of the functionality.
It works well with a single file, but fails like I showed when I do it for a directory. I think you can drop the issue, remove context menu for the directories or add a specific error message.
What I wanted was to have a generic text form to paste some text into, not uploading an existing file.
Now I understand that I need to just create a new file for this or select some text in an existing file
-
staff Hey Peter,
No you didn’t get it wrong: a snippet can be created with a directory (including nested directories) or multiple selected files. So I’m sure what you faced is a legit bug, some kind of edge case which I currently haven’t figured out. I have few ideas of possible edge cases which might cause Bitbucket to consider the request as invalid (as it returned 400 response back):
- unsupported characters in file/directory names – I tried with accented characters, hieroglyphs and emojis but that worked just fine
- unsupported characters in the snippet name – tried that too, worked fine
- empty directory – worked fine too
- too many files in the create snippet request – how many files did the directory have in your case?
- too large single file or overall file size – how large was the directory you tried to create the snippet from?
- hard or symbolic links in the scope – maybe Linky doesn’t handle links properly?
It’d be very helpful if you could create and share a minimal project where the problem can be reproduced, or if you can enable debug logging and hopefully find the payload of the 400 response from Bitbucket in the log – it might give a hint on what exactly Bitbucket considered invalid.
What I wanted was to have a generic text form to paste some text into, not uploading an existing file.
Now I understand that I need to just create a new file for this or select some text in an existing file
Yeah there’s no functionality like this right now cause I never considered such scenario to be common in IDE, and I never heard about any demand before. It shouldn’t be hard to add it, but I reckon it shouldn’t be triggered from the context menu in that case as it will not be relevant to the entity the menu is shown for.
Cheers,
Daniil -
staff - changed status to on hold
- Log in to comment