potpie-ai/potpie

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

Offen

#726 geöffnet am 06.04.2026

 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (642 Forks)auto 404
buggood first issuehelp wantedmaintenance

Repository-Metriken

Stars
 (5.521 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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)

Contributor Guide