Replies: 1 comment
-
It was probably an issue back then, but in current version this endpoint works well.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Issue
Open browser to swagger docs.
Try out endpoint: /api/v1/users/me (Read user me).
This resulted in error:
sqlalchemy.exc.StatementError: (builtins.AttributeError) 'str' object has no attribute 'hex'
[SQL: SELECT user.email AS user_email, user.is_active AS user_is_active, user.is_superuser AS user_is_superuser, user.full_name AS user_full_name, user.id AS user_id, user.hashed_password AS user_hashed_password
FROM user
WHERE user.id = ?]
[parameters: [{'pk_1': '80288216-dddd-558b-965b-e62ed65f22ec'}]]
Cause
In the function
get_current_user
SQLAlchemy tries to bind the string value to the UUID column, it's trying to call the hex method on the string, which doesn't exist.Solution
Convert the string to a UUID object before passing it to session.get. You can do this using the uuid.UUID constructor.
See example code above.
Operating System
macOS
Operating System Details
Apple Silicon.
Browser: Brave.
Python Version
Python 3.12.4
Additional Context
I replaced PostgreSQL with SQLite when I came across this issue.
Fixed it but not sure how and if this can be incorporated into the official Github project.
PS: I only say an option to create an issue for "security issues" this isn't that so I created the discussion here.
I can create a pull request for this, if you want.
Beta Was this translation helpful? Give feedback.
All reactions