Forum Discussion

Former Member's avatar
Former Member
3 years ago

1Password CLI 2 error creating with JSON

Hi folks,

I'm using op cli v2 to create a new 1Password item from JSON description of it. Passing the JSON as --template=item.json works, but passing the JSON to via stdin fails. The two behaviours that were not what I expected where:

  • I'd expect to able to item via stdin so as to not save secret values to disk
  • I'd expect the CONCEALED type values to be hidden/masked rather than printed to the terminal

Here are the steps to reproduce (the keys in the example are harmless):

```
$ /usr/local/bin/op --version
2.1.0
$ shasum /usr/local/bin/op
3ffc1c1db3e1eff0c22e1bf5ed3c8ea93ea2b6b5 /usr/local/bin/op
$ cat item.json
{
"title": "User age Key",
"category": "PASSWORD",
"fields": [
{
"id": "password",
"type": "CONCEALED",
"purpose": "PASSWORD",
"value": "age1kndvm4dhnqyd9kezkq8rx6wgswxa6n67p6jxsg5he52sy74ppuzq60l7a2"
},
{
"id": "publicKey",
"label": "publicKey",
"type": "STRING",
"value": "AGE-SECRET-KEY-1DG2WSCURXN5VWUU3SEMWGJXCVK42SD7EV08QYEF2TZHU65ZS0JNQKVFW98"
}
]
}

$ cat item.json | /usr/local/bin/op item create - # fails
[ERROR] 2022/05/24 15:04:48 Failed to create item: invalid JSON
$ /usr/local/bin/op item create --template=item.json # works
ID: ov22thm6cmiudojecu7ax5apeq
Title: User age Key
Created: now
Updated: now
Favorite: false
Version: 0
Category: PASSWORD
Fields:
password: age1kndvm4dhnqyd9kezkq8rx6wgswxa6n67p6jxsg5he52sy74ppuzq60l7a2
publicKey: AGE-SECRET-KEY-1DG2WSCURXN5VWUU3SEMWGJXCVK42SD7EV08QYEF2TZHU65ZS0JNQKVFW98
Additional Information: Tue May 24 15:05:19 SAST 2022
```

If I've made a mistake with JSON formatting, is it possible to point me to documentation on the format?


1Password Version: 8.7.0
Extension Version: N/A
OS Version: macOS 12.3

No Replies