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

Logout throws Validation Error when using next branch #5298

Closed
gertzakis opened this issue Feb 16, 2024 · 2 comments · Fixed by #5322
Closed

Logout throws Validation Error when using next branch #5298

gertzakis opened this issue Feb 16, 2024 · 2 comments · Fixed by #5322
Assignees
Labels
emergent Unplanned work that is brought into a sprint after it's started. type: bug Something isn't working as expected
Milestone

Comments

@gertzakis
Copy link
Contributor

Environment

  • Nautobot version (Docker tag too if applicable): v2.2.0a1
  • Python version: 3.8
  • Database platform, version: Postgres
  • Middleware(s):

This is applicable when using the next branch with version v2.2.0a1.

Steps to Reproduce

  1. Login with a User
  2. Logout

Expected Behavior

Logout successfully

Observed Behavior

A ValidationError is thrown at /logout/ with message ['“4ci8je1rmskkfei3g8avd9mt2da2bft5” is not a valid UUID.'] when I use the next branch.

@gertzakis gertzakis added type: bug Something isn't working as expected triage This issue is new and has not been reviewed. labels Feb 16, 2024
@glennmatthews
Copy link
Contributor

Thanks for filing the issue! We actually just noticed this bug yesterday on the core team. :-)

The issue is in the _handle_deleted_object signal, which is being triggered when the user logs out and their session DB record gets deleted. This signal is missing logic to handle the case where the deleted object has a PK that isn't of type UUID. A first pass fix is something like:

diff --git a/nautobot/extras/signals.py b/nautobot/extras/signals.py
index 86ad2aca8..17a31217c 100644
--- a/nautobot/extras/signals.py
+++ b/nautobot/extras/signals.py
@@ -20,6 +20,7 @@ from django_prometheus.models import model_deletes, model_inserts, model_updates
 
 from nautobot.core.celery import app, import_jobs_as_celery_tasks
 from nautobot.core.utils.config import get_settings_or_config
+from nautobot.core.utils.data import is_uuid
 from nautobot.extras.choices import JobResultStatusChoices, ObjectChangeActionChoices
 from nautobot.extras.constants import CHANGELOG_MAX_CHANGE_CONTEXT_DETAIL
 from nautobot.extras.models import (
@@ -165,6 +166,10 @@ def _handle_deleted_object(sender, instance, **kwargs):
     if change_context_state.get() is None:
         return
 
+    if not is_uuid(instance.pk):
+        # Probably some system object
+        return
+
     associations = ContactAssociation.objects.filter(
         associated_object_type=ContentType.objects.get_for_model(type(instance)), associated_object_id=instance.pk
     )

but we're having some discussions about whether there may be a more elegant way to fix it.

@glennmatthews glennmatthews removed the triage This issue is new and has not been reviewed. label Feb 16, 2024
@HanlinMiao HanlinMiao added this to the v2.2 milestone Feb 21, 2024
@glennmatthews glennmatthews self-assigned this Feb 21, 2024
glennmatthews added a commit that referenced this issue Feb 21, 2024
@glennmatthews glennmatthews linked a pull request Feb 22, 2024 that will close this issue
3 tasks
@glennmatthews glennmatthews added the emergent Unplanned work that is brought into a sprint after it's started. label Feb 22, 2024
glennmatthews added a commit that referenced this issue Feb 22, 2024
* Fix #5298

* Fix an issue with viewing JobResults missing a date_done value
@glennmatthews
Copy link
Contributor

Fixed by #5322.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emergent Unplanned work that is brought into a sprint after it's started. type: bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants