Skip to content

[Bug]: Fix duplicate create_user call in setup_dummy_user#818

Open
omnialp wants to merge 2 commits into
potpie-ai:mainfrom
omnialp:fix/issue-726-duplicate-create-user
Open

[Bug]: Fix duplicate create_user call in setup_dummy_user#818
omnialp wants to merge 2 commits into
potpie-ai:mainfrom
omnialp:fix/issue-726-duplicate-create-user

Conversation

@omnialp

@omnialp omnialp commented May 27, 2026

Copy link
Copy Markdown

Summary

Fixes #726setup_dummy_user was calling create_user twice with the same user object. The second duplicate call would 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

Changes

  • Removed the duplicate uid, _, _ = user_service.create_user(user) line in app/modules/users/user_service.py

Testing

The fix is straightforward — a single redundant line was removed. No test changes needed as existing tests continue to verify the correct behavior.

Fixes #726

Summary by CodeRabbit

  • Refactor
    • Internal code improvement with no user-facing changes.

Review Change Stack

The setup_dummy_user method was calling create_user twice with the same
user object. The first call correctly creates the user, but the second
duplicate call either raises an IntegrityError (unique constraint
violation) or silently overwrites the uid with an empty string.

This fix removes the duplicate call so the user is only created once.

Fixes potpie-ai#726
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5cf0142-9d2a-4f4a-9615-cfb72d3a19e7

📥 Commits

Reviewing files that changed from the base of the PR and between 0c5c7ec and 66a08a3.

📒 Files selected for processing (1)
  • app/modules/users/user_service.py
💤 Files with no reviewable changes (1)
  • app/modules/users/user_service.py

Walkthrough

This PR fixes a bug in UserService.setup_dummy_user where create_user was called twice with the same user object, causing either an IntegrityError or silent uid corruption. The fix removes the duplicate call and ensures all return values (uid, message, error) are properly captured from the single call.

Changes

Dummy User Initialization Fix

Layer / File(s) Summary
Remove duplicate create_user and capture all return values
app/modules/users/user_service.py
setup_dummy_user now calls create_user(user) once and destructures all three return values (uid, message, error) instead of making a duplicate call that would overwrite uid with an empty value or raise an IntegrityError.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A duplicate call caused quite a fright,
Creating the user once, then twice in the night,
But now with a fix, just one call it takes,
And all values captured—no more mistakes! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing a duplicate create_user call in setup_dummy_user, which is the primary objective of this pull request.
Linked Issues check ✅ Passed The pull request addresses the core requirement from issue #726 by removing the duplicate create_user call that was causing IntegrityError or uid corruption in setup_dummy_user.
Out of Scope Changes check ✅ Passed The changes are narrowly focused on the reported bug; capturing previously unused return values is a minor adjustment aligned with fixing the duplicate call issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@omnialp

omnialp commented Jun 6, 2026

Copy link
Copy Markdown
Author

Hi maintainers, just a gentle bump on this PR. It's a small fix for the duplicate create_user call in setup_dummy_user (addressing issue #726).

I noticed there are now merge conflicts with the base branch — I'm happy to resolve those and update the PR if you'd like to have this reviewed. Would appreciate a look when you have time. Thanks! 🙏

…te-create-user

# Conflicts:
#	legacy/app/modules/users/user_service.py
@omnialp

omnialp commented Jun 6, 2026

Copy link
Copy Markdown
Author

Update: I've resolved the merge conflict with the main branch. The directory restructuring caused the conflict — I've merged the latest main and the fix (removing the duplicate create_user call) is intact. Ready for review.

@Dsantra92 Dsantra92 added the maintenance Support for maintaining deprecated modules label Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Support for maintaining deprecated modules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants