Item missing from some commands

jamesarosen
jamesarosen
Community Member
edited December 2024 in CLI

I recently moved an item into a new vault (called MyVault below). op read works for this item, but op inject only works for a single value at a time, and only if that value was just read via op read.

$ op --version
2.30.3

# op read knows about Secret1
$ op read op://MyVault/MyItem/MySection/Secret1
secret value #1

# op inject works for Secret1:
$ echo "Secret1: op://MyVault/MyItem/MySection/Secret1" | op inject
Secret1: secret value #1

# op read knows about Secret2
$ op read op://MyVault/MyItem/MySection/Secret2
secret value #2

# now op inject knows about Secret2
$ echo "Secret2: op://MyVault/MyItem/MySection/Secret2" | op inject
Secret 2: secret value #2

# but now it forgets about Secret1
$ echo "Secret1: op://MyVault/MyItem/MySection/Secret1" | op inject
[ERROR] 2024/12/29 23:17:25 could not find item MyItem in vault MyVault, because it has been deleted or archived. Please restore the item if you want to use it with secret provisioning

# in fact, it forgets about the secret as soon as inject "consumes"
# the apparently-cached value from op read:
$ op read op://MyVault/MyItem/MySection/Secret1
secret value #1
$ echo "Secret1: op://MyVault/MyItem/MySection/Secret1" | op inject
Secret1: secret value #1
$ echo "Secret1: op://MyVault/MyItem/MySection/Secret1" | op inject
[ERROR] 2024/12/29 23:17:25 could not find item MyItem in vault MyVault, because it has been deleted or archived. Please restore the item if you want to use it with secret provisioning

1Password Version: 1Password for Mac 8.10.56 (81056028)
Extension Version: Not Provided
OS Version: macOS 14.5
Browser: Not Provided

Comments

  • jamesarosen
    jamesarosen
    Community Member
    edited December 2024

    I did some more digging and discovered that I had two versions of MyVault/MyItem: one live version and one archived. If I unarchive the archived one, I get a new error message:

    [ERROR] 2024/12/30 07:21:47 could not resolve item UUID for item MyItem: More than one item matches "MyItem". Try again and specify the item by its ID:
        * for the item "MyItem" in vault MyVault: d5lfmhvqvimg525dfhg6bu72v4
        * for the item "MyItem" in vault MyVault: 6wvpfiaaqrqcvhyo7bbzx35zxi
    

    Permanently deleting the archived copy resolves the issue.

    This is definitely a bug. At minimum, the CLI should give a better error message, e.g.

    [ERROR] 2024/12/30 07:21:47 could not resolve item UUID for item MyItem: More than one item matches "MyItem". Try again and specify the item by its ID:
        * for the item "MyItem" in vault MyVault: d5lfmhvqvimg525dfhg6bu72v4
        * for the archived item "MyItem" in vault MyVault: 6wvpfiaaqrqcvhyo7bbzx35zxi
    

    It might also make sense to automatically prefer non-archived items to archived ones. The app itself won't show the archived one unless I specifically search for it in the Archive. There isn't even a hint in the main search that there are other matches elsewhere. That makes the UI and the CLI work at odds.