Skip to content

Candidature: correction d'une erreur d'acceptation dans de rares conditions#4522

Merged
calummackervoy merged 1 commit intomasterfrom
calum/fix-date-format
Aug 8, 2024
Merged

Candidature: correction d'une erreur d'acceptation dans de rares conditions#4522
calummackervoy merged 1 commit intomasterfrom
calum/fix-date-format

Conversation

@calummackervoy
Copy link
Contributor

🤔 Pourquoi ?

CertifiedCriteriaInfoRequiredForm utilise un champ birthdate qui est anticipé d'être une date, mais c'est dans l'utilisation c'est possible que c'est un str, qui cause un ValueError

🍰 Comment ?

  • Enforcer que le birthdate dans CertifiedCriteriaInfoRequiredForm est une date
  • Sur _accept, ratrappe le cas rare où le date est mis à jour en string, et le convertir
  • Ajout des tests pour CertifiedCriteriaInfoRequiredForm

🚨 À vérifier

  • Mettre à jour le CHANGELOG_breaking_changes.md ?

@calummackervoy calummackervoy added the modifié Modifié dans le changelog. label Aug 6, 2024
@calummackervoy calummackervoy self-assigned this Aug 6, 2024
Copy link
Contributor

@tonial tonial left a comment

Choose a reason for hiding this comment

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

Je pense que tu peux améliorer la façon dont on passe birthdate à CertifiedCriteriaInfoRequiredForm.
J'ai fait 2 propositions mais je ne suis pas encore sur de quelle est la meilleurs 🤔 cela peut valoir le coup d'en discuter rapidement en SU, ou de demander l'avis à d'autres dev.

Il faudrait également que tu ajoute un test dans tests/www/apply/test_process.py::ProcessAcceptViewsTest qui plante comme dans sentry avant ta correction car pour l'instant on ne garanti pas que le problème ne se reproduira pas : typiquement si quelqu'un rechange ton birthdate = parse_date(birthdate) aucun test ne casse.

expected_msg = (
f"Le code INSEE {birth_place.code} n'est pas référencé par l'ASP en date du {early_date:%d/%m/%Y}"
)
assert form.errors["birth_place"] == [expected_msg]
Copy link
Contributor

Choose a reason for hiding this comment

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

Merci pour les tests sur le formulaire !

Copy link
Contributor

@celine-m-s celine-m-s left a comment

Choose a reason for hiding this comment

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

Merci beaucoup ! 🎉

…uiredForm

fix accept candidate: clean birthdate when passing to CertifiedCriteriaInfoRequiredForm
@calummackervoy calummackervoy force-pushed the calum/fix-date-format branch from 13d6e3f to a66a85d Compare August 7, 2024 12:11
Comment on lines +55 to +60
try:
birthdate = JobSeekerPersonalDataForm.base_fields["birthdate"].clean(
form_personal_data.data.get("birthdate")
)
except ValidationError:
pass # will be presented to user later
Copy link
Member

Choose a reason for hiding this comment

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

Pourquoi ne pas faire if form_personal_data.is_valid(): ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pour éviter qu'un autre champ invalide va empêcher la validation du birth_place sur CertifiedCriteriaInfoRequiredForm

Copy link
Member

Choose a reason for hiding this comment

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

Ok. C’est plus compliqué que nécessaire pour un cas très à la marge, mais comme tu préfères.

@francoisfreitag
Copy link
Member

Attention, le titre des PRs est utilisé pour communiquer les changements au utilisateurs. Mieux vaut le reformuler pour expliquer un peu plus ce qui a été changé (notamment erreur 500 qui n’est pas très parlant)

Copy link
Member

@francoisfreitag francoisfreitag left a comment

Choose a reason for hiding this comment

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

Autrement LGTM, merci d’avoir fixé le problème 💯

Copy link
Contributor

@tonial tonial left a comment

Choose a reason for hiding this comment

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

Super !

@calummackervoy calummackervoy changed the title Candidature: Fix erreur 500 sur l'acceptation siae sous les conditions rares Candidature: prévention du erreur sur l'acceptation siae sous les conditions rares Aug 8, 2024
@calummackervoy calummackervoy changed the title Candidature: prévention du erreur sur l'acceptation siae sous les conditions rares Candidature: correction d'une erreur d'acceptation du siae dans de rares conditions Aug 8, 2024
@calummackervoy calummackervoy added this pull request to the merge queue Aug 8, 2024
Merged via the queue into master with commit 602fde2 Aug 8, 2024
@calummackervoy calummackervoy deleted the calum/fix-date-format branch August 8, 2024 08:20
@francoisfreitag francoisfreitag changed the title Candidature: correction d'une erreur d'acceptation du siae dans de rares conditions Candidature: correction d'une erreur d'acceptation dans de rares conditions Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

modifié Modifié dans le changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments