Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soucis lors de la suppression d'un user avec un avatar inexistant #1659

Open
maudetes opened this issue Jan 29, 2025 · 0 comments
Open

Soucis lors de la suppression d'un user avec un avatar inexistant #1659

maudetes opened this issue Jan 29, 2025 · 0 comments
Labels
💙 Back Les tickets de back Bug Indique qu’il s’agit d’un problème

Comments

@maudetes
Copy link
Contributor

maudetes commented Jan 29, 2025

La suppression d'un user (DELETE /api/1/users/<user_id>) renvoie parfois une 500 lors d'une suppression.

C'est lié au fait qu'un avatar est renseigné mais le fichier n'a pas/plus l'air d'exister au moment de sa suppression.

Exemple d'erreur sentry

stacktrace
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/datagouv/avatars/2e/72da8cc2eb481b8bed14ad750bc832.png'
  File "flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "udata/api/__init__.py", line 103, in wrapper
    return func(*args, **kwargs)
  File "flask_restx/api.py", line 404, in wrapper
    resp = resource(*args, **kwargs)
  File "flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
  File "flask_restx/resource.py", line 46, in dispatch_request
    resp = meth(*args, **kwargs)
  File "udata/api/__init__.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "udata/core/user/api.py", line 320, in delete
    user.mark_as_deleted(notify=not args["no_mail"])
  File "udata/core/user/models.py", line 243, in mark_as_deleted
    storage.delete(self.avatar.filename)
  File "flask_storage/storage.py", line 260, in delete
    return self.backend.delete(filename)
  File "flask_storage/backends/local.py", line 90, in delete
    os.remove(dest)

L'erreur arrive aussi lors d'une purge d'organisation avec l'avatar non trouvé (erreur sentry).

Enquêter sur la non existence du fichier avatar.
A voir pour être résilient, tout en loggant un warning/erreur sur sentry.

@maudetes maudetes converted this from a draft issue Jan 29, 2025
@maudetes maudetes moved this to 📝 Todo in 🚀 Produit data.gouv.fr Jan 29, 2025
@maudetes maudetes added Bug Indique qu’il s’agit d’un problème 💙 Back Les tickets de back labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💙 Back Les tickets de back Bug Indique qu’il s’agit d’un problème
Projects
Status: 📝 Todo
Development

No branches or pull requests

1 participant