potpie-ai/potpie

[Bug] High: create_user called twice in setup_dummy_user — causes IntegrityError or corrupts uid

Aperta

#726 aperta il 6 apr 2026

 (3 commenti) (0 reazioni) (0 assegnatari)Python (642 fork)auto 404
buggood first issuehelp wantedmaintenance

Metriche repository

Star
 (5521 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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, uid is silently set to an incorrect value
  • Any downstream logic relying on uid from 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)

Guida contributor