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

babashka stash/get hangs #2

Closed
judepayne opened this issue Mar 6, 2023 · 7 comments
Closed

babashka stash/get hangs #2

judepayne opened this issue Mar 6, 2023 · 7 comments

Comments

@judepayne
Copy link

Hi,
I'm using your babashka scripting examples. The stash-get function which in turn calls stash/get on the pod seems to hang indefinitely.

(with an empty stash)

parson.stash> (stash-init "password") ;; stash-init copied from scripting-examples
true
parson.stash> (add-entry "facebook.com" "jude@test")
1
parson.stash> (stash-nodes)
[{:key "facebook.com",
  :hvalue "09b5867c284533237f3d726c91242c842af91925c38c57bd038d5da0d6b47eb82e6db80f77e4e55da3aabc9c1fbe915e413c5125b5b768eabf8214e8be512bb9",
  :value "jude@test",
  :created "2023-03-05T22:03:08Z",
  :modified "2023-03-05T22:03:08Z",
  :id 1,
  :parent-id 0,
  :hkey "df72bcf65b6a475d0f1aa1751dc567a7ba24a50f2e3ea13489933632e0157385ee6a634a2bc9dfcdad89d71ea957cbd1bff9d8c9d6d4202af0727a2401dc5dff",
  :version 1}]
parson.stash> (stash-get 0 "facebook.com").  ;; hangs indefinitely 

I've tried (stash-get "facebook.com"), which also hangs.

thanks!

@judepayne
Copy link
Author

add-entry just wraps stash\nodes putting the key value into parent-id 0

@rorokimdim
Copy link
Owner

@judepayne thanks for reporting this.

do you mind sharing how you've defined add-entry so i could debug?

stash-get accepts a list of keys, and if i get that right seems to work for me.

But if (stash-get "facebook.com") didn't work for you there must be a bug, so I'll need to look into it.

Does (stash-browse) work ?

Could you also try the following in your repl:

Babashka v1.1.172 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (doc stash-add)
-------------------------
user/stash-add
([parent-id k v])
  Adds a new node under a parent.
nil
user=> (stash-add 0 "facebook.com" "jude@test")
1
user=> (stash-nodes)
[{:key "facebook.com", :hvalue "6419149a9412e49c4b6ca48c7410737ac16f6298a2a3a73c4c9c2c6540700aef1e33705e1cc4ec7db16b245f2db4435302a4e842545614960cf5c028edb37189", :value "jude@test", :created "2023-03-12T06:15:13Z", :modified "2023-03-12T06:15:13Z", :id 1, :parent-id 0, :hkey "ca3b65a7531e111ab2cbb0f999ece1020880f47bfd3c1cbb7d838c65b82d6734e696ed779906ca3108e6f7d84bd8877e1e214e76f0532af254aaa38a65cb5552", :version 1}]
user=> (stash-get "facebook.com")
"jude@test"
user=>

@judepayne
Copy link
Author

judepayne commented Mar 12, 2023

@rorokimdim, thanks for coming back on this!

Try this sequence to reproduce the error (function definitions are exactly as in your scripting-examples\babashka\stash.clj):

stash> (stash-init "password")
true
stash> (stash-add 0 "facebook.com" "jude@test")
1
stash> (stash-get "facebook.com")
"jude@test.com".   ;; this is fine as per yours above
stash> (stash-get 0 "facebook.com")
;; this hangs indefinitely.

I must have mistakenly assumed since your data structure is a tree and the arguments to this function are [& ks] that you had to pass the full path (in the tree) down to the node that you wanted. (rather than thinking that the any node could be received directly from its key).

This should throw an error rather than hang.

I found other examples of this hanging after raising this issue to you. Possibly the same issue- passing in unexpected arguments?? If you fix this, I'll certainly report any other issues back here.

ps. I had some questions on how the overall cryptographic scheme works in stash. I'll ask them on another issue. thanks!

@rorokimdim
Copy link
Owner

rorokimdim commented Mar 12, 2023

Cool. I did see the issue when i tried exactly that.

It appears to be related to how the error message is encoded by stash and how babashka-pod tries to decode it -- it expects ex-data to be a json-encoded map which is not the case.

I can't remember if the error handling ever worked in the babashka sample code. Or I tested in an ancient version for babashka pod.

This should be easy to fix -- i'll try to put a fix when i get some time. I just need to change the format of ex-data i believe. The python version does not care about the format so it doesn't have the same problem.

@rorokimdim
Copy link
Owner

@judepayne do u mind trying out the latest version when you get a chance. thank you!

@judepayne
Copy link
Author

judepayne commented Mar 13, 2023

Hi,
That's better. I am now getting an error instead!

parson.stash> (stash-add 0 "facebook.com" "jude@test")
clojure.lang.ExceptionInfo: Key already exists parson.stash /Users/jude/Dropbox/Projects/clojure/parson/src/parson/stash.clj:28:3

Thanks a lot! If I find any other issues, will be sure to report them

@rorokimdim
Copy link
Owner

awesome.

i'll close this then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants