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

KeyError raised when Subject ID is not a URI #2488

Closed
Ennovate-com opened this issue Sep 10, 2023 · 2 comments
Closed

KeyError raised when Subject ID is not a URI #2488

Ennovate-com opened this issue Sep 10, 2023 · 2 comments

Comments

@Ennovate-com
Copy link
Contributor

Ennovate-com commented Sep 10, 2023

In valid.py, the line:
subjects = value if isinstance(value, list) else [value]
converts a single value to a single-element list in subjects, which ensures that subjects will always be a list. However, later on, value is treated as a dictionary rather than a list:
uri_validator(value["id"])

And in another place, it is treated as a list subscripted with the integer 0:
f"credential subject id {value[0]} must be URI"'
In this case, if value is not a list, a KeyError 0 error is raised.

Once subjects has been assigned and is known to be a list, using the subject makes more sense than continuing to use the value having an ambiguous type.

2023-09-10 03:31:33,181 aries_cloudagent.admin.server ERROR Handler error with exception: 0
=================
Traceback (most recent call last):
  File "/aries_cloudagent/messaging/valid.py", line 753, in __call__
    uri_validator(value["id"])
  File "/usr/local/lib/python3.9/site-packages/marshmallow/validate.py", line 499, in __call__
    raise ValidationError(self._format_error(value))
marshmallow.exceptions.ValidationError: Value 123-45-6789_Dating is not URI

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  ...
  File "/aries_cloudagent/messaging/valid.py", line 756, in __call__
    f"credential subject id {value[0]} must be URI"
KeyError: 0
2023-09-10 03:31:33,183 aiohttp.server ERROR Error handling request
Traceback (most recent call last):
  File "/aries_cloudagent/messaging/valid.py", line 753, in __call__
    uri_validator(value["id"])
  File "/usr/local/lib/python3.9/site-packages/marshmallow/validate.py", line 499, in __call__
    raise ValidationError(self._format_error(value))
marshmallow.exceptions.ValidationError: Value 123-45-6789_Dating is not URI

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  ...
  File "/aries_cloudagent/messaging/valid.py", line 756, in __call__
    f"credential subject id {value[0]} must be URI"
KeyError: 0
@Ennovate-com
Copy link
Contributor Author

Fixed in PR #2490

dbluhm added a commit that referenced this issue Sep 14, 2023
Issue #2488 KeyError raised when Subject ID is not a URI
@dbluhm
Copy link
Member

dbluhm commented Sep 18, 2023

Fixed!

@dbluhm dbluhm closed this as completed Sep 18, 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

2 participants