CLI "item create" works only form console on Mac Monterrey 12.5, TouchID is activated.
Hello, dear community members,
here is what I encounter: when I try to run a script from PyCharm or Automator for "item get" - everything works
when I try to run a script from PyCharm or Automator for "item create" - nothing happens, even though it shows that the script worked through and successfully finished, it doesn't prompt me with Touch ID, as it does with "item get" command.
when I run any command or script from the console - everything works.
here is the simple script for both ways (via os and subprocess):
import os
import subprocess
placing_into_1p = subprocess.check_output(["op", "item", "create", "--category", "'secure note'", "--title='123'"])
s_note = "op item create --category 'secure note' --title='Netflix3' 'notesPlain=my test secret' --tags='Test'"
os.system(s_note)
Thank you for any ideas that might help me to go forward with this.
Cheers,
Dmitrii
1Password Version: 8.8.0
Extension Version: 2.3.7
OS Version: macOS 12.5
Browser:_ Chrome 104.0.5112.79 (Official Build) (arm64)
Comments
-
Hey Dmitrii, thank you for reaching out to us!
I think you're encountering a known bug, where the CLI mistakenly detects piped input in some programatic environments (i.e. scripts, wrappers etc.) when in fact there is none. The workaround for the moment is to pipe some input in the command.
For example, instead of
op item create --category "secure note" --title 123
you could do:
echo "{\"title\":\"123\"}" | op item create --category "secure note"
We're sorry for this inconvenience. We're currently working to fix this.
Let us know if this workaround helps, in the meantime.
Best,
Horia0 -
Hello Horia,
thank you for getting back to me, unfortunately, this workaround didn't work for me...
It gives me the following error:[ERROR] 2022/08/16 12:05:12 invalid character 't' looking for beginning of object key string
And if I remove 't' from the title word - it gives me the same error but with letter 'i'
Besties,
Dmitrii0 -
UPD: the previous message was from a Python script. And now I managed to run it via bash script from Automator. I will keep you updated =) Thank you!
0 -
Glad you're making progress! Let us know if we can help you.
Theinvalid character
error usually appears when in situations where some escaping/quoting is needed, so feel free to drop a code snippet here, if you'd like our eyes on that :DBest,
Horia0 -
Hey Dmitrii,
We just released CLI 2.6.2, which we expect to solve this issue. Let us know if that works for you!
https://app-updates.agilebits.com/product_history/CLI2#v2060201Best,
Horia0 -
Yes, you are right, I've found the invalid json syntax. When adding escaping characters it gets tricky when the command is quite big =)
Thank you for your help!
I will check the new release later (I don't want to touch what already works =))))))Besties,
Dmitrii0 -
Just checked the new version, and I couldn't make it work for me.
import os
bash_string = "op item create --category 'secure note' --title='Netflix1' --tags='Test'"
os.system(bash_string)
Besties,
Dmitrii0 -
Hey Dmitrii,
I just ran the snippet above and it works as expected for me. Can you please confirm that
op --version
returns2.6.2
or2.7.1-beta.01
?
Also, how do you run your script? I ran mine withpython3 main.py
.Looking forward to hearing from you.
Best,
Horia0