Skip to content

Use get() with error logging instead of filter().first() in tasks.py #678

@ravshanovdev

Description

@ravshanovdev

In backend/accounts/tasks.py, the current code uses:

email_obj = AccountEmail.objects.filter(id=email_obj_id).first()

This silently returns None if the object is not found, making it
hard to debug failures in production.

Suggested fix:

try:
email_obj = AccountEmail.objects.get(id=email_obj_id)
except AccountEmail.DoesNotExist:
logger.error(f"AccountEmail id={email_obj_id} not found, skipping task.")
return

This way, missing objects are logged properly instead of failing silently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions