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

When creating a Datasource, Input Field Checking is not always enforced #4632

Closed
riversdev0 opened this issue Mar 17, 2022 · 9 comments
Closed
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@riversdev0
Copy link
Contributor

riversdev0 commented Mar 17, 2022

Describe the bug

If you have a custom field attached to a Data Input Method, that field will only be validated for acceptable data upon being edited, not upon creation.

To Reproduce

Steps to reproduce the behavior:

  1. Create a Data Input Method with a custom Input Field
    image

  2. Set a Regular Expression Match on the Input Field
    image

  3. Create a Data Source Template that allows the user to modify the value of Input Field
    image

  4. Create a Graph Template referencing that Data Source Template

  5. Add a graph using that template to a device. Set the Custom Data to something outside the range of the validation pattern.
    image

  6. Edit the brand new Data Source and observe that the value is out of range.
    image

  7. Save the Data Source with no changes. Observe that the validation fails.
    image

Expected behavior

I would expect the Input Field Checking validation pattern to be enforced upon creation of the Data Source, just as it is during the modification of the Data Source.

Version info

  • Cacti 1.2.19

Additional context

I'm willing to help fix this, but some others probably know from memory where the relevant code is located.

@riversdev0 riversdev0 added bug Undesired behaviour unverified Some days we don't have a clue labels Mar 17, 2022
@TheWitness
Copy link
Member

Never used that feature, though I can see why it's handy.

@TheWitness
Copy link
Member

So, question, I'm assuming you are manually creating the data source rather than doing so using the template engine. Is this a correct assumption?

@riversdev0
Copy link
Contributor Author

riversdev0 commented Mar 17, 2022

The way I'm creating the graph is by navigating to the Device, and clicking "*Create Graphs for this Device" and picking the Graph Template from the drop down. This method was used to produce the screenshots above.

I do have a point of confusion, however, about how the process described in the sentence above is different than picking the Graph Template directly from the Device page, without first clicking "*Create Graphs for this Device". Here's a screenshot of what I'm referring to, "directly on the Device page".
image

My confusion is that if I add the graph directly from the Device page, Cacti "remembers" the graph being there, as illustrated in this screenshot:
image

Yet, if I create the graph from the "*Create Graphs for this Device" page, cacti doesn't display any evidence that the device has the graph (except it does appear on the "Graphs" page, and it does fully work, there is just no evidence on the Device page).

@TheWitness
Copy link
Member

The process is somewhat confusing, but glad you clarified.

TheWitness added a commit that referenced this issue Mar 18, 2022
Input Field Checking is not enforced upon creation of Data Source
@TheWitness TheWitness removed the unverified Some days we don't have a clue label Mar 18, 2022
@TheWitness TheWitness added this to the v1.2.20 milestone Mar 18, 2022
@TheWitness
Copy link
Member

You will have to force load your pages include/layout.js, but after which, you should be able to test this.

@TheWitness TheWitness added the resolved A fixed issue label Mar 18, 2022
@TheWitness
Copy link
Member

@riversdev0, just checking in to see if you are satisfied with the fix...

@riversdev0
Copy link
Contributor Author

Sorry for the slow response. I've been having issues getting it to work correctly, but it might be my fault. I integrated the changes into my prod Cacti installation and here's what it does:

When creating a new graph, I enter an invalid value in the field and click "Create". The page goes blank white and does nothing. I click on some other navigation item, and I get a pop-up that says "Save Failed due to field input errors (Check red fields)" overlaid on the unrelated page to which I navigated. I can view other unrelated pages and then circle back to creating the same graph again. When I attempt to create the graph a second time, when it displays the fields again, the field into which I typed the invalid value is now highlighted red, but it contains the default value, not my invalid value.

I can clone the development branch onto a dev server and see if the issues happens there. Would you like me to test that?

@TheWitness
Copy link
Member

You need to force reload the new layout. Browsers like chrome make it hard without clearing your cache.

@riversdev0
Copy link
Contributor Author

Ok, I tried it in a Private browser window and I was able to see the error message, and was able to correct the value, and the new graph was created. I think the change worked as expected! Thank you!

@netniV netniV changed the title Input Field Checking is not enforced upon creation of Data Source When creating a Datasource, Input Field Checking is not always enforced Apr 3, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants