Commit 6cfc4c7
committed
Do not raise AttributeError when parsing non-string UUIDs
When a user sends a dictionary or other object as a UUID variable like `{[123]}`, previously graphene crashed with an `AttributeError`, like this:
```
(…)
File "…/lib/python3.12/site-packages/graphql/utils/is_valid_value.py", line 78, in is_valid_value
parse_result = type.parse_value(value)
^^^^^^^^^^^^^^^^^^^^^^^
File "…/lib/python3.12/site-packages/graphene/types/uuid.py", line 33, in parse_value
return _UUID(value)
^^^^^^^^^^^^
File "/usr/lib/python3.12/uuid.py", line 175, in __init__
hex = hex.replace('urn:', '').replace('uuid:', '')
^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'replace'
```
But an `AttributeError` makes it seem like this is the server's fault, when it's obviously the client's.
Report a proper GraphQLError.1 parent ccae736 commit 6cfc4c7
2 files changed
+18
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
39 | 54 | | |
40 | 55 | | |
41 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
0 commit comments