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

Validate process dates depending on enabled phases #4521

Merged
merged 5 commits into from
May 29, 2021
Merged

Conversation

javierm
Copy link
Member

@javierm javierm commented May 20, 2021

References

Objectives

  • Fix a bug where the application crashed when enabling a phase and leaving its dates blank

Notes

Existing invalid data won't be fixed by this pull request, so the application will still crash if invalid data exists. However, it won't be possible to generate new invalid data.

@javierm javierm added the Bug label May 20, 2021
@javierm javierm self-assigned this May 20, 2021
@javierm javierm added this to Reviewing in Consul Democracy via automation May 20, 2021
@javierm javierm changed the title Phases exception Validate process dates depending on enabled phases May 20, 2021
@javierm javierm force-pushed the phases_exception branch 2 times, most recently from e988c0f to 3df491d Compare May 20, 2021 23:14
Consul Democracy automation moved this from Reviewing to Testing May 28, 2021
We had tests for other phases, but not for these ones.
So now it uses the same rules as the other phases.
So now they're easier to change and we make sure the same rules apply to
all phases.
When configuring phases in a process, we were validating the start date
or the end date is present, the other date is present too.

However, in other parts of the application we were checking whether a
phase is enabled and then assumed its dates were present if the phase
was enabled. However, we weren't validating this behavior, so it was
possible to enable a phase and leaving its dates blank, causing the
application to crash.

So, as suggested by Alberto, we're changing the validation rule so
phase dates are mandatory when a phase is enabled.

With this rule, the old validation rules are not necessary. I've
considered leaving them in order to avoid database inconsistencies.
However, I realized records having a disabled phase with its start and
end dates have always been valid. This means applications checking for
the presence of these dates instead of checking whether the phase is
enabled have never worked properly.

We don't have to change the logic anywhere else because as mentioned we
were already checking phases are enabled before using their dates.
@javierm javierm merged commit 216fe8f into master May 29, 2021
@javierm javierm deleted the phases_exception branch May 29, 2021 12:28
Consul Democracy automation moved this from Testing to Release 1.3.1 May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error on processes with the comments phase's blank date
2 participants