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

Do not raise AttributeError when parsing non-string UUIDs #1582

Merged
merged 2 commits into from
Nov 9, 2024

Commits on Nov 7, 2024

  1. 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.
    phihag committed Nov 7, 2024
    Configuration menu
    Copy the full SHA
    6cfc4c7 View commit details
    Browse the repository at this point in the history

Commits on Nov 9, 2024

  1. Configuration menu
    Copy the full SHA
    e354759 View commit details
    Browse the repository at this point in the history