You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{createClient,ItemFieldType}from'@1password/sdk';constop=awaitcreateClient({auth: '...',integrationVersion: '1',integrationName: 'test-script',});constitem=awaitop.items.get(VAULT_ID,matchingItem.id);awaitop.items.put({
...item,fields: [{id: genId(),title: itemField.fieldName,value: itemField.fieldValue,fieldType: ItemFieldType.Concealed,sectionId: undefined,// tried '', null, undefined, and omitting the sectionId field},],});
I've found this API tough to use... First, I have to create my own field id, which feels like none of my business to do. I'm just generating a 26 length random string of upper/lower/number characters (see below)... This however, does seem to satisfy the error I was getting when I didn't provide a field id: data did not match any variant of untagged enum Invocation.
Second and what is currently blocking me, is that the claim in the sectionId documentation does not seem to be working correctly. See ItemField definition:
exportinterfaceItemField{/** The field's ID */id: string;/** The field's title */title: string;/** The ID of the section containing the field. Built-in fields such as usernames and passwords don't require a section. */sectionId?: string;/** The field's type */fieldType: ItemFieldType;/** The string representation of the field's value */value: string;/** Field type-specific attributes. */details?: ItemFieldDetails;}
Reading this again now... maybe it is because it is not a Built-in field? However, I do not want these in a section, I want them at the same level as the built-in fields like I can create in the 1pass desktop client...
Actual Behavior
invalid user input: encountered the following errors: custom field with id 'nLs9cXU2bD0Xg1Z0vBWpBv4Yrb' must be part of a section
Expected Behavior
The field can be created when omitting the sectionId or when setting it to undefined.
SDK version
0.1.3
Additional information
Here is the code for genId in case others find it useful. Or maybe the sdk could provide a function to generate IDs? Or maybe they can just be omitted when creating fields. I know this is not cryptographically ideal, but I suppose it does not matter as much for IDs? Also just chose 26 as the length as I found another id was that long.
I've gotten around this by just printing out CLI commands to use instead...
op item edit --vault 'MY_VAULT' 'MY_ITEM_NAME' 'MY_FIELD_NAME=MY_FIELD_VALUE'
For now this is sufficient as I just needed to do a one-time import of existing development values in a .env file as we are switching to 1password security automation.
Just noticed when I retrieved an item that had non-builtin fields in what I refer to as the 'default' section, or just fields outside any section. The item provided a single section in the sections array which had '' for both the id and name...
Do I need to first create a section with an empty ID and/or name to replicate the behavior of adding a field to the default section in the Desktop App?
Scenario & Reproduction Steps
I've found this API tough to use... First, I have to create my own field id, which feels like none of my business to do. I'm just generating a 26 length random string of upper/lower/number characters (see below)... This however, does seem to satisfy the error I was getting when I didn't provide a field id:
data did not match any variant of untagged enum Invocation
.Second and what is currently blocking me, is that the claim in the
sectionId
documentation does not seem to be working correctly. SeeItemField
definition:Reading this again now... maybe it is because it is not a Built-in field? However, I do not want these in a section, I want them at the same level as the built-in fields like I can create in the 1pass desktop client...
Actual Behavior
Expected Behavior
The field can be created when omitting the
sectionId
or when setting it toundefined
.SDK version
0.1.3
Additional information
Here is the code for
genId
in case others find it useful. Or maybe the sdk could provide a function to generate IDs? Or maybe they can just be omitted when creating fields. I know this is not cryptographically ideal, but I suppose it does not matter as much for IDs? Also just chose 26 as the length as I found another id was that long.The text was updated successfully, but these errors were encountered: