Skip to content

Comments

Fix for account screen server error#1169

Merged
xzzy merged 1 commit intodbca-wa:masterfrom
xzzy:master2
Feb 12, 2026
Merged

Fix for account screen server error#1169
xzzy merged 1 commit intodbca-wa:masterfrom
xzzy:master2

Conversation

@xzzy
Copy link
Collaborator

@xzzy xzzy commented Feb 12, 2026

No description provided.

@xzzy xzzy merged commit 44c6dd1 into dbca-wa:master Feb 12, 2026
2 of 3 checks passed
if person_id is None:
if "email" in self.initial:
print (self.initial['email'])
person_id = EmailUser.objects.get(email=self.initial['email'])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The user lookup by email assigns the full EmailUser object to person_id instead of its ID, causing a ValueError on a later type conversion. It also lacks a try...except block, risking an unhandled DoesNotExist exception.
Severity: HIGH

Suggested Fix

Modify the query to retrieve the user's ID directly by appending .id or .pk. Additionally, wrap the EmailUser.objects.get() call in a try...except EmailUser.DoesNotExist block to gracefully handle cases where the email does not exist in the database.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: ledger/accounts/forms.py#L215

Potential issue: When the form is initialized with an email but no ID, the code at
`ledger/accounts/forms.py:215` looks up the user. This lookup has two failure modes.
First, if a user is found, the entire `EmailUser` object is assigned to `person_id`, not
its integer ID. This object is later stringified (e.g., to 'user@example.com') and
stored in a hidden form field. When the form is submitted, an attempt to convert this
string back to an integer via `int()` will raise a `ValueError`. Second, if no user is
found for the provided email, the `EmailUser.objects.get()` call will raise an unhandled
`EmailUser.DoesNotExist` exception, causing a server error.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant