potpie-ai/potpie
[Bug] High: create_user called twice in setup_dummy_user — causes IntegrityError or corrupts uid
Open
#726 opened on Apr 6, 2026
buggood first issuehelp wantedmaintenance
Repository metrics
- Stars
- (5,521 stars)
- PR merge metrics
- (PR metrics pending)
Description
Summary
In user_service.py, setup_dummy_user calls create_user twice with the same user object. The second call either raises an IntegrityError or silently overwrites uid with an empty string, corrupting the dummy user setup flow.
File
app/modules/users/user_service.py, setup_dummy_user method (~lines 129-130)
Description
uid, message, error = user_service.create_user(user) # Creates user correctly
uid, _, _ = user_service.create_user(user) # Bug: duplicate call!
The second create_user(user) call is identical to the first. Since the user was already created, it will either:
- Raise a database
IntegrityError(unique constraint violation), rolling back and logging an error - Return an empty/error
uid, silently overwriting the correct value from the first call
Impact
- Development mode initialization (
setup_dummy_user) can fail entirely - If it doesn't fail,
uidis silently set to an incorrect value - Any downstream logic relying on
uidfrom this function will behave incorrectly
Suggested Fix
Remove the duplicate call entirely:
# Before (broken):
uid, message, error = user_service.create_user(user)
uid, _, _ = user_service.create_user(user) # remove this line
# After (fixed):
uid, message, error = user_service.create_user(user)