Skip to content

Cannot add custom fields via Python sdk which can be fetched with terraform provider #128

@joaquin-borggio-lc

Description

@joaquin-borggio-lc

Scenario & Reproduction Steps

I am looking to setup some automation where I sink secrets to 1password via the SDK (via our 1password connect server) and then read them into infrastructure modules via the 1password provider.

I see that I can create an item like this:

            # Convert fields to SDK format
            sdk_fields = []
            if fields:
                for field in fields:
                    sdk_fields.append(Field(
                        label=field.label,
                        value=field.value,
                        type=field.field_type,
                        purpose=field.purpose
                    ))

            # Create item
            new_item = Item(
                title=item_name,
                fields=sdk_fields,
                category="LOGIN",
            )

            created_item = self.client.create_item(vault_id, new_item)
            self.logger.info(f"Created item '{item_name}' in vault '{vault}'")

and the item appears in 1password UI like this:

Image

but then when i query for the item via the terraform provider, I dont see these custom fields:

terraform output -json       
{
  "debug_tf_vars": {
    "sensitive": true,
    "type": [
      "object",
      {
        "category": "string",
        "credential": "string",
        "database": "string",
        "file": [
          "list",
          [
            "object",
            {
              "content": "string",
              "content_base64": "string",
              "id": "string",
              "name": "string"
            }
          ]
        ],
        "hostname": "string",
        "id": "string",
        "note_value": "string",
        "password": "string",
        "port": "string",
        "private_key": "string",
        "public_key": "string",
        "section": [
          "list",
          [
            "object",
            {
              "field": [
                "list",
                [
                  "object",
                  {
                    "id": "string",
                    "label": "string",
                    "purpose": "string",
                    "type": "string",
                    "value": "string"
                  }
                ]
              ],
              "file": [
                "list",
                [
                  "object",
                  {
                    "content": "string",
                    "content_base64": "string",
                    "id": "string",
                    "name": "string"
                  }
                ]
              ],
              "id": "string",
              "label": "string"
            }
          ]
        ],
        "tags": [
          "list",
          "string"
        ],
        "title": "string",
        "type": "string",
        "url": "string",
        "username": "string",
        "uuid": "string",
        "vault": "string"
      }
    ],
    "value": {
      "category": "login",
      "credential": null,
      "database": null,
      "file": [],
      "hostname": null,
      "id": "vaults/<redacted-vault-id>/items/<redacted-item-id>",
      "note_value": "",
      "password": "",
      "port": null,
      "private_key": null,
      "public_key": null,
      "section": [],
      "tags": null,
      "title": "test",
      "type": null,
      "url": null,
      "username": "",
      "uuid": "<redacted-item-id>",
      "vault": "<redacted-vault-id>"
    }
  }
}

However, if i create a "Login" item in the UI, I can actually pull those fields. Below is an example:

I create this item (basically identical to the item i created via the sdk):

Image

and then i try to read it via the terraform provider (reading it from outputs), I can actually see the custom fields:

"debug_tf_vars_works": {
    "sensitive": true,
    "type": [
      "object",
      {
        "category": "string",
        "credential": "string",
        "database": "string",
        "file": [
          "list",
          [
            "object",
            {
              "content": "string",
              "content_base64": "string",
              "id": "string",
              "name": "string"
            }
          ]
        ],
        "hostname": "string",
        "id": "string",
        "note_value": "string",
        "password": "string",
        "port": "string",
        "private_key": "string",
        "public_key": "string",
        "section": [
          "list",
          [
            "object",
            {
              "field": [
                "list",
                [
                  "object",
                  {
                    "id": "string",
                    "label": "string",
                    "purpose": "string",
                    "type": "string",
                    "value": "string"
                  }
                ]
              ],
              "file": [
                "list",
                [
                  "object",
                  {
                    "content": "string",
                    "content_base64": "string",
                    "id": "string",
                    "name": "string"
                  }
                ]
              ],
              "id": "string",
              "label": "string"
            }
          ]
        ],
        "tags": [
          "list",
          "string"
        ],
        "title": "string",
        "type": "string",
        "url": "string",
        "username": "string",
        "uuid": "string",
        "vault": "string"
      }
    ],
    "value": {
      "category": "login",
      "credential": null,
      "database": null,
      "file": [],
      "hostname": null,
      "id": "vaults/<redacted-vault-id>/items/<redacted-item-id>",
      "note_value": "",
      "password": "",
      "port": null,
      "private_key": null,
      "public_key": null,
      "section": [
        {
          "field": [
            {
              "id": "oa2o7hzh5nlcyc7ghqjfar32ja",
              "label": "key",
              "purpose": "",
              "type": "STRING",
              "value": "valuee"
            },
            {
              "id": "wtk4ibbqtjcy3yposcy6d5erki",
              "label": "foo",
              "purpose": "",
              "type": "STRING",
              "value": "bar"
            }
          ],
          "file": [],
          "id": "add more",
          "label": ""
        }
      ],
      "tags": null,
      "title": "test2",
      "type": null,
      "url": null,
      "username": "",
      "uuid": "<redacted-item-id>",
      "vault": "<redacted-vault-id>"
    }
  }
}

Please advise on how to resolve this. We need to be able to set and read custom fields in a 1password item via the sdk and 1password connect server ideally. Thank you !

Actual Behavior

Any way where i can create an item with custom fields via the sdk which we can then fetch via the terraform provider.

Expected Behavior

Having a way to read and write custom fields via the python sdk and the terraform provider

SDK version

onepasswordconnectsdk>=2.0.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions