Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ItemCategory.PASSWORD: custom field with id 'username' must be part of a section #144

Open
cimnine opened this issue Jan 6, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@cimnine
Copy link

cimnine commented Jan 6, 2025

Scenario & Reproduction Steps

I try to create an item with ItemCategory.PASSWORD. I add a field with id='username', section_id=None and field_type=ItemFieldType.TEXT:

ItemField(
        id='username',
        title='username',
        field_type=ItemFieldType.TEXT,
        value='test@test',
        section_id=None
)

Actual Behavior

Error creating entry 0: msg="invalid user input: encountered the following errors: custom field with id 'username' must be part of a section"

Expected Behavior

No error.

SDK version

0.1.5

Additional information

In the 1Password client, I can set a username for a Password-type item no problem.

@cimnine cimnine added the bug Something isn't working label Jan 6, 2025
@cimnine
Copy link
Author

cimnine commented Jan 6, 2025

When reading back the updated value via the SDK client, I see that the 1Password client converted the item from an ItemCategory.PASSWORD to a ItemCategory.Login. Please document this, as it's not obvious.

In general, it would be great to have documentation, which ItemCategory allows which fields to appear without section_id and what their expected field_id and category are.

@Marton6
Copy link
Member

Marton6 commented Jan 7, 2025

Hi @cimnine! Thanks for filing this issue.

In general, it would be great to have documentation, which ItemCategory allows which fields to appear without section_id and what their expected field_id and category are.

I agree we will look into documenting that!

custom field with id 'username' must be part of a section

This is actually an expected error. If you want to add more fields to an item you can do so by adding them to a section. If you'd like them to show up in the UI as "top level" fields, without a section name, you should add them to a section that has an empty name (""). I realize this is also behavior we haven't documented yet.

@Marton6
Copy link
Member

Marton6 commented Jan 7, 2025

When reading back the updated value via the SDK client, I see that the 1Password client converted the item from an ItemCategory.PASSWORD to a ItemCategory.Login. Please document this, as it's not obvious.

It shouldn't be possible for item categories to change. Could you clarify what steps have you taken and what behavior you've observed. I would like to understand this occurrence better

@cimnine
Copy link
Author

cimnine commented Jan 7, 2025

It shouldn't be possible for item categories to change. Could you clarify what steps have you taken and what behavior you've observed. I would like to understand this occurrence better

  1. Using the API or 1Password GUI, creating an item with ItemCategory.PASSWORD.
    Item(
      id='jzimb4nuqdmdvhl37pwanfisnu',
      title='Password',
      category=<ItemCategory.PASSWORD: 'Password'>,
      vault_id='npxkqz4al6qbcqb7qgpjxngt6y',
      fields=[
        ItemField(id='password', title='password', section_id=None, field_type=<ItemFieldType.CONCEALED: 'Concealed'>, value='TEST', details=None)
      ],
      sections=[],
      tags=[],
      websites=[],
      version=1
    )
    
  2. In the 1Password Desktop client, adding a username:
    image
  3. Using the API, reading the same item again. It's now of type ItemCategory.LOGIN:
    Item(
      id='jzimb4nuqdmdvhl37pwanfisnu',
      title='Password',
      category=<ItemCategory.LOGIN: 'Login'>,
      vault_id='npxkqz4al6qbcqb7qgpjxngt6y',
      fields=[
        ItemField(id='password', title='password', section_id=None, field_type=<ItemFieldType.CONCEALED: 'Concealed'>, value='TEST', details=None),
        ItemField(id='username', title='username', section_id=None, field_type=<ItemFieldType.TEXT: 'Text'>, value='NOW_ADDED', details=None)
      ],
      sections=[],
      tags=[],
      websites=[],
      version=2
    )
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants