Skip to content

Support field lookup by field.id as fallback to field.label#131

Open
AlonNaor22 wants to merge 1 commit into1Password:mainfrom
AlonNaor22:feat/field-id-lookup
Open

Support field lookup by field.id as fallback to field.label#131
AlonNaor22 wants to merge 1 commit into1Password:mainfrom
AlonNaor22:feat/field-id-lookup

Conversation

@AlonNaor22
Copy link

Summary

  • Extends load_dict and load to resolve fields by field.id when a field.label match is not found
  • Lookup order: label first → id second → raise error (as described in load_dict and load work with field id and label #50)
  • Section lookup also extended to support both section.label and section.id

Files changed

  • src/onepasswordconnectsdk/config.py — extracted reusable _find_field() and _match_field() helpers, added FIELD_MATCH_ATTRIBUTES constant for configurable lookup order, extended _convert_sections_to_dict() to support section id keys
  • src/tests/test_config.py — 3 new tests: field id lookup via load_dict, field id lookup via load, and label-takes-priority verification

Test plan

  • Existing test_load and test_load_dict still pass (no regressions)
  • test_load_dict_by_field_id — verifies field.id fallback with load_dict
  • test_load_by_field_id — verifies field.id fallback with load
  • test_load_dict_label_takes_priority — verifies label match wins over id match

Note: Some pre-existing async tests in test_client_items.py and test_client_vaults.py fail due to a missing pytest-asyncio dependency — are these expected to pass? Our changes don't touch those files.

Closes #50

🤖 Generated with Claude Code

@github-actions
Copy link

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

Extend load_dict and load to resolve fields by field.id when a
field.label match is not found. The lookup order is: label first,
then id, then raise an error. Section lookup is also extended to
support both section.label and section.id.

Closes 1Password#50

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

load_dict and load work with field id and label

1 participant