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

Unable to save settings when SOTAGG enabled #856

Closed
msheiny opened this issue Jan 3, 2025 · 3 comments
Closed

Unable to save settings when SOTAGG enabled #856

msheiny opened this issue Jan 3, 2025 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@msheiny
Copy link

msheiny commented Jan 3, 2025

Environment

  • Python version: 3.12.8
  • Nautobot version: 2.3.1
  • nautobot-golden-config version: bda93e16e0434edc0a603bc106af1cb49d8cd5c6

Expected Behavior

Following the user guide, section First Steps with App as a brand-new user who has limited nautobot interaction.

I should be able to add a git repository source and then setup the backup configuration and hit save as instructed in the directions.

Observed Behavior

I'm unable to save because the clean method on the model will not allow you to post an empty sot_agg_query field if the ENABLE_SOTAGG is enabled. This is listed as a setting that is enabled in the installation guide configuration to copy/paste and is also enabled in the development environment for this repo.

I receive the following error when trying to save:
image

Which is confusing because the form doesn't high-light it's referring to the "Sot agg query" setting under the Templates Configuration which I have not modfiied:

image

Steps to Reproduce

  1. Follow the directions from the docs on a new nautobot instance
  2. Proceed to add a git repository source
  3. Try to update the golden config settings pointing to that repo as a backup configuration source -> encounter error

Proposed fix

The error is coming from here. So obviously fix is to modify that if statement to also check if the jinja_repository field is not empty before throwing an error.

I would also suggest modifying the form to high-light when that field is missing/required. As a new user with a technical background, it was not immediately obvious to me which field that warning message was talking about it.

@msheiny msheiny added bug Something isn't working documentation Improvements or additions to documentation labels Jan 3, 2025
@itdependsnetworks itdependsnetworks removed the bug Something isn't working label Jan 3, 2025
@itdependsnetworks
Copy link
Contributor

I'm unable to save because the clean method on the model will not allow you to post an empty sot_agg_query field if the ENABLE_SOTAGG is enabled

This is as intended, I understand your point on the user experience of it, though I am not sure the juice is worth the squeeze, and you will see this pattern throughout Nautobot, as shown in this example below.

image

In general, in forms.py, when you inherit from NautobotModelForm it will introspect the model and update accordingly, however, it does not account for logic within the clean method of the model, as that can be anything. I see it as we can:

  1. Modify the widget attrs in the init method as shown here: https://github.com/nautobot/nautobot/blob/8052fe6749e98ff81f678f85402b349e67543a97/nautobot/extras/forms/forms.py#L235 with some complex logic
  2. Ping @glennmatthews if there is another option
  3. Do nothing, as it works as intended and uses established patterns.

@msheiny
Copy link
Author

msheiny commented Jan 3, 2025 via email

@itdependsnetworks
Copy link
Contributor

got it, fixed in #857

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants