Skip to content

Évite une 500 si le formulaire de profil ne contient pas tous les champs#6777

Merged
artragis merged 2 commits intozestedesavoir:devfrom
philippemilink:fix-partial-profile-form
Jan 23, 2026
Merged

Évite une 500 si le formulaire de profil ne contient pas tous les champs#6777
artragis merged 2 commits intozestedesavoir:devfrom
philippemilink:fix-partial-profile-form

Conversation

@philippemilink
Copy link
Member

Sentry nous rapporte l'erreur suivante :

Traceback (most recent call last):
  File "django/utils/datastructures.py", line 84, in __getitem__
    list_ = super().__getitem__(key)
KeyError: 'biography'

Traceback (most recent call last):
  File "django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/views/generic/base.py", line 105, in view
    return self.dispatch(request, *args, **kwargs)
  File "django/utils/decorators.py", line 48, in _wrapper
    return bound_method(*args, **kwargs)
  File "django/contrib/auth/decorators.py", line 59, in _view_wrapper
    return view_func(request, *args, **kwargs)
  File "zds/member/views/profile.py", line 223, in dispatch
    return super().dispatch(*args, **kwargs)
  File "django/views/generic/base.py", line 144, in dispatch
    return handler(request, *args, **kwargs)
  File "zds/member/views/profile.py", line 257, in post
    return self.form_valid(form)
  File "zds/member/views/profile.py", line 263, in form_valid
    self.update_profile(profile, form)
  File "zds/member/views/profile.py", line 271, in update_profile
    profile.biography = form.data["biography"]
  File "django/utils/datastructures.py", line 86, in __getitem__
    raise MultiValueDictKeyError(key)
MultiValueDictKeyError: 'biography'

Lors de la mise à jour de son profil, le champ biography n'est pas présent dans les données de la requête POST. En regardant le contenu de la requête, les autres champs sont présents. Je ne comprends pas bien comment l'absence de biography a pu se produire, mais on ne peut pas faire l'hypothèse que ce champ nous est bien envoyé.

Cette PR corrige ce problème, j'ai ajouté les tests correspondants et j'ai refactorisé quelques bouts de codes

Contrôle qualité

La CI passe.

Essayer de modifier les différents éléments de son profil et s'assurer que ça fonctionne toujours.

@philippemilink philippemilink added S-BUG Corrige un problème C-Back Concerne le back-end Django labels Jan 18, 2026
@github-project-automation github-project-automation bot moved this to En développement in Suivi des PR Jan 18, 2026
@coveralls
Copy link

coveralls commented Jan 18, 2026

Coverage Status

coverage: 89.434% (+0.09%) from 89.34%
when pulling a4d3660 on philippemilink:fix-partial-profile-form
into a92dcf2 on zestedesavoir:dev.

Copy link
Member

@artragis artragis left a comment

Choose a reason for hiding this comment

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

Je suis pas sûr qu'un test à la main soit nécessaire vu que le test unitaire ajouté montre clairement le cas initial. A part le petit changement demandé, je pense qu'on peut y aller.

@github-project-automation github-project-automation bot moved this from En développement to Modification demandée in Suivi des PR Jan 18, 2026
- Ajoute les tests corresondants
- Refactorise le code
@philippemilink philippemilink force-pushed the fix-partial-profile-form branch from 9a8ecb6 to a4d3660 Compare January 21, 2026 21:17
@philippemilink philippemilink moved this from Modification demandée to En attente de QA in Suivi des PR Jan 21, 2026
@github-project-automation github-project-automation bot moved this from En attente de QA to Fusionnable après rebase in Suivi des PR Jan 23, 2026
@artragis artragis merged commit 4fa8a77 into zestedesavoir:dev Jan 23, 2026
12 checks passed
@github-project-automation github-project-automation bot moved this from Fusionnable après rebase to Fusionnée in Suivi des PR Jan 23, 2026
@philippemilink philippemilink deleted the fix-partial-profile-form branch January 23, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Back Concerne le back-end Django S-BUG Corrige un problème

Projects

Status: Fusionnée

Development

Successfully merging this pull request may close these issues.

3 participants

Comments