potpie-ai/potpie
[Bug] High: create_user called twice in setup_dummy_user — causes IntegrityError or corrupts uid
开放
#726 创建于 2026年4月6日
buggood first issuehelp wantedmaintenance
仓库指标
- 星标
- (5,521 个星标)
- PR 合并指标
- (PR 指标待抓取)
描述
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)