Items created through CLI have mixed/repeated custom fields in Web UI
Hi,
I published a post about this issue previously but I am unable to find it anywhere.
When creating entries through CLI, entries are poorly displayed in Web UI and seems to break Mac App also.
I investigated more on this topic and here is a simple reproductible code example:
#!/usr/bin/env bash set -e SESSION=$(op signin $SUBDOMAIN --output=raw) ENCODED_REQUEST_1=$( (cat <<EOF { "notesPlain": "", "sections": [ { "name": "", "title": "", "fields": [ { "t": "UUID", "v": "c503036c-94f7-4580-a766-06858bd0ba26", "k": "string" } ] }, { "name": "lastpass", "title": "Lastpass", "fields": [ { "k": "string", "t": "LASTPASS_ID", "v": "12345678" }, { "t": "FOLDER", "v": "Archive", "k": "string" }, { "t": "SHARE", "v": null, "k": "string" }, { "t": "LASTPASS_FULL_NAME", "v": "Archive/test_entry1", "k": "string" }, { "t": "Type", "v": "Site", "k": "string" } ] } ], "passwordHistory": [], "fields": [ { "value": "username", "name": "username", "type": "T", "designation": "username" }, { "value": "password", "name": "password", "type": "P", "designation": "password" } ] } EOF ) | op encode ) op create item Login ${ENCODED_REQUEST_1} --url="https://test1.com" --title="First entry" --session=$SESSION ENCODED_REQUEST_2=$(cat <<EOF | op encode { "notesPlain": "", "sections": [ { "name": "", "title": "", "fields": [ { "t": "UUID", "v": "c503036c-94f7-4580-a766-06858bd0ba26", "k": "string" } ] }, { "name": "lastpass", "title": "Lastpass", "fields": [ { "k": "string", "t": "LASTPASS_ID", "v": "456789" }, { "t": "FOLDER", "v": "Archive", "k": "string" }, { "t": "SHARE", "v": null, "k": "string" }, { "t": "LASTPASS_FULL_NAME", "v": "Archive/test_entry2", "k": "string" }, { "t": "Type", "v": "Site", "k": "string" } ] } ], "passwordHistory": [], "fields": [ { "value": "username", "name": "username", "type": "T", "designation": "username" }, { "value": "password", "name": "password", "type": "P", "designation": "password" } ] } EOF ) op create item Login ${ENCODED_REQUEST_2} --url="https://test2.com" --title="Second entry" --session=$SESSION ENCODED_REQUEST_3=$(cat <<EOF | op encode { "notesPlain": "", "sections": [ { "name": "", "title": "", "fields": [ { "t": "UUID", "v": "c503036c-94f7-4580-a766-06858bd0ba26", "k": "string" } ] }, { "name": "lastpass", "title": "Lastpass", "fields": [ { "k": "string", "t": "LASTPASS_ID", "v": "09876" }, { "t": "FOLDER", "v": "Archive", "k": "string" }, { "t": "SHARE", "v": null, "k": "string" }, { "t": "LASTPASS_FULL_NAME", "v": "Archive/test_entry3", "k": "string" }, { "t": "Type", "v": "Site", "k": "string" } ] } ], "passwordHistory": [], "fields": [ { "value": "username", "name": "username", "type": "T", "designation": "username" }, { "value": "password", "name": "password", "type": "P", "designation": "password" } ] } EOF ) op create item Login ${ENCODED_REQUEST_3} --url="https://test3.com" --title="Third entry" --session=$SESSION
And the result in Web UI:
Am I missing something on the CLI usage ?
Thanks,
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Sync Type: Not Provided
Comments
-
@mickael What you're missing is the
n
field. Your fields in thesections
array should look like this:{ "k": "string", "n": "qxef6kxe54l26d5qzdqum3jk7u", "t": "asdf", "v": "asdf" }, { "k": "string", "n": "5zhmmejgijzy6e5y2cat53j3pm", "t": "asdf", "v": "asdffasfgsd" }
Where
k
is "string",n
is a random UUID (lowercase, len 26),t
is the field title, andv
is the value.Each section's
name
should also be something like:"name": "Section_gnw7y27o33nltsj2ld74coblm4",
, orSection_{random lowercase 29 len uuid}
Let me know if that works for you.
0 -
BTW, if you look at the template of the
Server
note, this is not very clear that we should generate UUID for fields. Maybe the template function should generate them automatically or at least replace by something likegenerateYourOwn26LenUUID
?{ "notesPlain": "", "sections": [ { "title": "", "name": "", "fields": [ { "k": "string", "n": "url", "v": "", "t": "URL" }, { "k": "string", "n": "username", "v": "", "t": "username" }, { "k": "concealed", "n": "password", "v": "", "t": "password" } ] }, { "title": "Admin Console", "name": "admin_console", "fields": [ { "k": "string", "n": "admin_console_url", "v": "", "t": "admin console URL" }, { "k": "string", "n": "admin_console_username", "v": "", "t": "admin console username" }, { "k": "concealed", "n": "admin_console_password", "v": "", "t": "console password" } ] }, { "title": "Hosting Provider", "name": "hosting_provider_details", "fields": [ { "k": "string", "n": "name", "v": "", "t": "name" }, { "k": "string", "n": "website", "v": "", "t": "website" }, { "k": "string", "n": "support_contact_url", "v": "", "t": "support URL" }, { "k": "string", "n": "support_contact_phone", "v": "", "t": "support phone" } ] } ] }
0 -
@cohix ok. Is it the same thing for fields outside sections ?
For example:
{ "notesPlain": "", "sections": [], "passwordHistory": [], "fields": [ { "value": "", "name": "username", "type": "T", "designation": "username" }, { "value": "", "name": "password", "type": "P", "designation": "password" } ] }
Do I have to change also the name here ?
0 -
Those are standard and only login or password items can have them, so those should stay exactly as you have them there.
0 -
@cohix Thanks a lot, I can confirm that so far it looks like working like a charm.
Really, really happy. It looks like I am near the end of my journey of escaping from Lastpass and that I found at last MY/OUR suitable password manager !
And, special mention for the support, also !
0