Skip to content

Improved error handling when license expiration is unset #971

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

Conversation

melinoix
Copy link
Contributor

Improving the error handling when license expiration is unset by catching error when licence_expiracy = "unset"

@@ -203,8 +203,11 @@ def get_build(request):
LICENSE_SEATS = settings.LICENSE_SEATS
LICENSE_EXPIRATION = settings.LICENSE_EXPIRATION
try:
expiration_iso = datetime.fromisoformat(LICENSE_EXPIRATION)
license_expiration = date_format(expiration_iso, use_l10n=True)
if LICENSE_EXPIRATION and LICENSE_EXPIRATION.lower() != "unset":
Copy link
Contributor

Choose a reason for hiding this comment

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

I would advise to wrap the date cast in a try/except block, instead of explicitly checking for an "unset" string.

expiration_iso = datetime.fromisoformat(LICENSE_EXPIRATION)
license_expiration = date_format(expiration_iso, use_l10n=True)
else:
license_expiration = "No expiration date set"
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have an error identifier here instead of an english string, e.g. "noExpirationDateSet". This would make it easier to translate it in the frontend.

Copy link
Collaborator

@Mohamed-Hacene Mohamed-Hacene left a comment

Choose a reason for hiding this comment

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

The error is also triggered here:
image

@nas-tabchiche nas-tabchiche force-pushed the CA-550-improve-error-handling-when-license-expiration-is-unset branch from fdb8aad to af7143a Compare November 13, 2024 14:15
Copy link
Contributor

@nas-tabchiche nas-tabchiche left a comment

Choose a reason for hiding this comment

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

LGTM

@nas-tabchiche nas-tabchiche merged commit ceb1b32 into main Nov 18, 2024
17 checks passed
@nas-tabchiche nas-tabchiche deleted the CA-550-improve-error-handling-when-license-expiration-is-unset branch November 18, 2024 11:09
@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants