fastapi/full-stack-fastapi-template · error · HTTPException

User with this email already exists

Error message

User with this email already exists

What it means

Error "User with this email already exists" thrown in fastapi/full-stack-fastapi-template.

Source

Thrown at backend/app/api/routes/users.py:92

            email_to=user_in.email,
            subject=email_data.subject,
            html_content=email_data.html_content,
        )
    return user


@router.patch("/me", response_model=UserPublic)
def update_user_me(
    *, session: SessionDep, user_in: UserUpdateMe, current_user: CurrentUser
) -> Any:
    """
    Update own user.
    """

    if user_in.email:
        existing_user = crud.get_user_by_email(session=session, email=user_in.email)
        if existing_user and existing_user.id != current_user.id:
            raise HTTPException(
                status_code=409, detail="User with this email already exists"
            )
    user_data = user_in.model_dump(exclude_unset=True)
    current_user.sqlmodel_update(user_data)
    session.add(current_user)
    session.commit()
    session.refresh(current_user)
    return current_user


@router.patch("/me/password", response_model=Message)
def update_password_me(
    *, session: SessionDep, body: UpdatePassword, current_user: CurrentUser
) -> Any:
    """
    Update own password.
    """
    verified, _ = verify_password(body.current_password, current_user.hashed_password)

View on GitHub (pinned to 8063fe54f1)

When it happens

Trigger: Thrown at backend/app/api/routes/users.py:92 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of fastapi/full-stack-fastapi-template@8063fe54f1 (2026-08-26). Data as JSON: /api/errors/5e0590e4423b280b. Report an issue: GitHub.