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

Show validation error message when object.validated_save() fails in ssot contrib #545

Closed
gioccher opened this issue Sep 11, 2024 · 4 comments
Assignees
Labels
integration: contrib Contrib related issues and PRs type: enhancement New feature or request

Comments

@gioccher
Copy link

gioccher commented Sep 11, 2024

Environment

  • Nautobot version: 2.2.9
  • nautobot-ssot version: 2.7.0

Proposed Functionality

In ssot.contrib, when creating/updating an object with data that fails the various validation constraints, the message "Validated save failed for Django object. Parameters: {.......}" is logged.
It would be more helpful to also log the contents of the django ValidationError that is raised, to give a hint of what went wrong.

Example:
log
Validated save failed for Django object: Interface with this Device and Name already exists. Parameters: {'name': 'port-channel12', 'device__name': 'xyz', 'description': 'something', 'enabled': True, 'type': 'other', 'mode': 'tagged', 'status__name': 'Active', 'lag__name': None, 'lag__device__name': None, 'untagged_vlan__vid': 33, 'untagged_vlan__name': 'foobar-dhcp', 'tagged_vlans': [{'vid': 33, 'name': 'foobar-dhcp'}, {'vid': 99, 'name': 'foobar-baz'}], 'trunk_groups': [], 'mgmt_only': False, 'vrf__name': None, 'vrf__namespace__name': None}
instead of
Validated save failed for Django object. Parameters: {'name': 'port-channel12', 'device__name': 'xyz', 'description': 'something', 'enabled': True, 'type': 'other', 'mode': 'tagged', 'status__name': 'Active', 'lag__name': None, 'lag__device__name': None, 'untagged_vlan__vid': 33, 'untagged_vlan__name': 'foobar-dhcp', 'tagged_vlans': [{'vid': 33, 'name': 'foobar-dhcp'}, {'vid': 99, 'name': 'foobar-baz'}], 'trunk_groups': [], 'mgmt_only': False, 'vrf__name': None, 'vrf__namespace__name': None}
(this one left me puzzled for a while since there were 14 parameters to check. It turned out I already had "Port-Channel12" and was trying to create "port-channel12")

Use Case

Easier troubleshooting of error messages

@jdrew82
Copy link
Contributor

jdrew82 commented Oct 2, 2024

So this particular error is actually coming from Django itself. With that in mind, there's nothing we can do to improve these messages so going to close this out.

@jdrew82 jdrew82 closed this as completed Oct 2, 2024
@gioccher
Copy link
Author

gioccher commented Oct 2, 2024

Hi, the "Validated save failed for Django object. Parameters: " comes from

raise ObjectCrudException(f"Validated save failed for Django object. Parameters: {parameters}") from error

The Django message "Interface with this Device and Name already exists" that clarifies why it failed is not included in the SSOT job or operations logs. That same Django message is shown when attempting to do the same invalid operation in the nautobot web interface, but not shown in SSOT.

@jdrew82 jdrew82 reopened this Oct 2, 2024
@jdrew82
Copy link
Contributor

jdrew82 commented Oct 2, 2024

Odd, I dunno why that didn't show when I searched for it. I'll get a PR in for modifying that message.

@jdrew82 jdrew82 self-assigned this Oct 2, 2024
@jdrew82 jdrew82 added type: enhancement New feature or request integration: contrib Contrib related issues and PRs labels Oct 2, 2024
@gioccher
Copy link
Author

gioccher commented Dec 6, 2024

Closing since #590 handles this. Thank you!

@gioccher gioccher closed this as completed Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration: contrib Contrib related issues and PRs type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants