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

load_dict fails when looking up keys with periods in them #44

Open
Joe-Still opened this issue May 20, 2022 · 1 comment
Open

load_dict fails when looking up keys with periods in them #44

Joe-Still opened this issue May 20, 2022 · 1 comment
Labels
bug Something isn't working tracked Issue is tracked in 1Password's internal ticketing system as well.

Comments

@Joe-Still
Copy link

Your environment

SDK Version: 1.2.0

  • installed via pip install onepasswordconnectsdk
    Connect Server Version:
    OS: Ubuntu 20.04
    Python Version: 3.8.10

What happened?

Using load_dict against a key with a period in it generates an error: onepasswordconnectsdk.config.InvalidFieldPathException

What did you expect to happen?

Retrieval of value matching that key

Steps to reproduce

Attempt to retreive a value matching a key with a . in it.
My case has been part of a Section.
`
from onepasswordconnectsdk.client import (
Client,
new_client_from_environment,
new_client
)
from onepasswordconnectsdk import (
load_dict
)

client: Client = new_client_from_environment()
account="[email protected]"
creds = load_dict(client, {
"pass": {
"opitem": "My Account",
"opfield": "Main Login." + account
}
})
`

Notes & Logs

Traceback (most recent call last):
File "test.py", line 45, in
creds = load_dict(client, {
File "/home/dev1/.local/lib/python3.8/site-packages/onepasswordconnectsdk/config.py", line 80, in load_dict
_set_values_for_item(client=client,
File "/home/dev1/.local/lib/python3.8/site-packages/onepasswordconnectsdk/config.py", line 185, in _set_values_for_item
raise InvalidFieldPathException(
onepasswordconnectsdk.config.InvalidFieldPathException: Invalid field path format for pass

It's understandable that the '.' is normally chaining fields to get one field deeper but keys with email addresses are common and keys with ip addresses are not uncommon in our particular setup.
I would expect either an attempt to look for keys with '.'s in them if it fails or a way to wrap it to escape the '.'s

@Joe-Still Joe-Still added the bug Something isn't working label May 20, 2022
@edif2008 edif2008 added the tracked Issue is tracked in 1Password's internal ticketing system as well. label May 30, 2022
@edif2008
Copy link
Member

edif2008 commented Jun 7, 2022

Hey @Joe-Still,

Currently the way load_dict works for the opfield is based on the following syntax: section.field. Therefore, having one or more dots in your field's name would throw an error in your case.

I do understand your use case and I've raised this with my team. We will update you when we make a new release with this fix.

Thank you for your patience 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked Issue is tracked in 1Password's internal ticketing system as well.
Projects
None yet
Development

No branches or pull requests

2 participants