potpie-ai/potpie

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

Aberta

#726 aberto em 6 de abr. de 2026

 (3 comentários) (0 reação) (0 responsável)Python (642 forks)auto 404
buggood first issuehelp wantedmaintenance

Métricas do repositório

Stars
 (5.521 estrelas)
Métricas de merge de PR
 (Mesclagem média 5d 8h) (25 fundiu PRs em 30d)

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, 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)

Guia do colaborador