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

Bug in rare case of trying to modify but pass empty dict #106

Open
merretbuurman opened this issue Mar 1, 2023 · 0 comments
Open

Bug in rare case of trying to modify but pass empty dict #106

merretbuurman opened this issue Mar 1, 2023 · 0 comments
Assignees

Comments

@merretbuurman
Copy link
Collaborator

This is a bug that can occur when we try to modify a handle record (via REST client), but pass an empty dict of changes.

In that case, pyhandle will try to return a variable that is not assigned, here:

https://github.com/EUDAT-B2HANDLE/PYHANDLE/blob/master/pyhandle/client/resthandleclient.py#L602

When the variable nothingchanges is True, the variable resp never gets defined or assigned, so we run into an exception here:

https://github.com/EUDAT-B2HANDLE/PYHANDLE/blob/master/pyhandle/client/resthandleclient.py#L578

pidify_1  |     self.__handle_client.modify_handle_value(handle, **record_kv)
pidify_1  |   File "/usr/local/lib/python3.12/site-packages/pyhandle/client/resthandleclient.py", line 490, in modify_handle_value
pidify_1  |     return self.__handle_modification(handle, ttl, add_if_not_exist, overwrite, **kvpairs)
pidify_1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pidify_1  |   File "/usr/local/lib/python3.12/site-packages/pyhandle/client/resthandleclient.py", line 602, in __handle_modification
pidify_1  |     return json.loads(decoded_response(resp))['handle']
pidify_1  |                                        ^^^^
pidify_1  | UnboundLocalError: cannot access local variable 'resp' where it is not associated with a value
@merretbuurman merretbuurman self-assigned this Mar 1, 2023
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

No branches or pull requests

1 participant