Signing back into the Community for the first time? You'll need to reset your password to access your account.  Find out more.

Forum Discussion

Former Member's avatar
Former Member
3 years ago

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)

  • Former Member's avatar
    Former Member

    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,
    Horia

  • Former Member's avatar
    Former Member

    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,
    Dmitrii

  • Former Member's avatar
    Former Member

    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!

  • Former Member's avatar
    Former Member

    Glad you're making progress! Let us know if we can help you.
    The invalid 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 :D

    Best,
    Horia

  • Former Member's avatar
    Former Member

    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,
    Dmitrii

  • Former Member's avatar
    Former Member

    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,
    Dmitrii

  • Former Member's avatar
    Former Member

    Hey Dmitrii,

    I just ran the snippet above and it works as expected for me. Can you please confirm that op --version returns 2.6.2 or 2.7.1-beta.01?
    Also, how do you run your script? I ran mine with python3 main.py.

    Looking forward to hearing from you.

    Best,
    Horia