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

Automation causes SQL syntax errors when invalid operations are present #4122

Closed
nuno-silva opened this issue Feb 10, 2021 · 6 comments
Closed
Labels
bug Undesired behaviour resolved A fixed issue

Comments

@nuno-silva
Copy link
Contributor

nuno-silva commented Feb 10, 2021

Describe the bug

Adding a new "Graph Create Criteria" to an Automation Graph Rule causes an SQL syntax error when and Operation is missing on an item.

To Reproduce

Steps to reproduce the behavior:

  1. Go to Automation -> Graph Rules

  2. Add a new Rule:

  • Name: something
  • Data Query: Net-SNMP - Get Monitored Partitions
  • Graph Type: Disk Space
  • Enable Rule: checked
  1. add two new Graph Creation Criteria, without "Operation", e.g. for field "dskPath", Operator "does not containt", pattern "bla". See screenshots if needed.

  2. Save

  3. Open log; see SQL errors

Expected behaviour

UI should notify user that the Graph Creation Criteria are invalid

Screenshots

image
Note that item#6 has no Operation, which causes the SQL syntax error.

Log entires

2021/02/10 19:18:23 - CMDPHP SQL Backtrace: (/automation_graph_rules.php[79]:automation_graph_rules_edit(), /automation_graph_rules.php[650]:display_new_graphs(), /lib/api_automation.php[866]:db_fetch_assoc(), /lib/database.php[476]:db_fetch_assoc_prepared(), /lib/database.php[490]:db_execute_prepared())
2021/02/10 19:18:23 - CMDPHP ERROR: A DB Row Failed!, Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a.`dskPath` NOT LIKE '%/home/welcomeab%') LIMIT 0,50' at line 1
2021/02/10 19:18:23 - CMDPHP SQL Backtrace: (/automation_graph_rules.php[79]:automation_graph_rules_edit(), /automation_graph_rules.php[650]:display_new_graphs(), /lib/api_automation.php[858]:db_fetch_assoc(), /lib/database.php[476]:db_fetch_assoc_prepared(), /lib/database.php[490]:db_execute_prepared())
2021/02/10 19:18:23 - CMDPHP ERROR: A DB Row Failed!, Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a.`dskPath` NOT LIKE '%/home/welcomeab%')' at line 1

Additional context

Cacti version: 1.2.16

@nuno-silva nuno-silva added bug Undesired behaviour unverified Some days we don't have a clue labels Feb 10, 2021
@TheWitness
Copy link
Member

Yea, this is something that needs more attention. It's clear that you have a bug in your syntax. That should be masked for the most part.

@TheWitness TheWitness removed the unverified Some days we don't have a clue label Feb 17, 2021
@TheWitness TheWitness changed the title autom8 causes SQL syntax errors when invalid Operations are present Automation causes SQL syntax errors when invalid Operations are present Feb 17, 2021
TheWitness added a commit that referenced this issue Feb 17, 2021
Automation causes SQL syntax errors when invalid Operations are present
@TheWitness TheWitness added the resolved A fixed issue label Feb 17, 2021
@TheWitness
Copy link
Member

Have an update to lib/api_automation.php and if the problem is now masked, please close.

@nuno-silva
Copy link
Contributor Author

hey @TheWitness , thanks for the patch.

It suppresses one of the errors, but there is still another error, e.g:

  • without the patch:

2021/02/17 21:35:56 - CMDPHP SQL Backtrace: (/automation_graph_rules.php[79]:automation_graph_rules_edit(), /automation_graph_rules.php[650]:display_new_graphs(), /lib/api_automation.php[866]:db_fetch_assoc(), /lib/database.php[476]:db_fetch_assoc_prepared(), /lib/database.php[490]:db_execute_prepared())
2021/02/17 21:35:56 - CMDPHP ERROR: A DB Row Failed!, Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a.`diskIODevice` LIKE '%s%') LIMIT 0,50' at line 1
2021/02/17 21:35:56 - CMDPHP SQL Backtrace: (/automation_graph_rules.php[79]:automation_graph_rules_edit(), /automation_graph_rules.php[650]:display_new_graphs(), /lib/api_automation.php[858]:db_fetch_assoc(), /lib/database.php[476]:db_fetch_assoc_prepared(), /lib/database.php[490]:db_execute_prepared())
2021/02/17 21:35:56 - CMDPHP ERROR: A DB Row Failed!, Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a.`diskIODevice` LIKE '%s%')' at line 1
  • with the patch:
2021/02/17 21:32:22 - CMDPHP SQL Backtrace: (/automation_graph_rules.php[79]:automation_graph_rules_edit(), /automation_graph_rules.php[650]:display_new_graphs(), /lib/api_automation.php[858]:db_fetch_assoc(), /lib/database.php[476]:db_fetch_assoc_prepared(), /lib/database.php[490]:db_execute_prepared())
2021/02/17 21:32:22 - CMDPHP ERROR: A DB Row Failed!, Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a.`diskIODevice` LIKE '%s%')' at line 1

This is what I used to reproduce it this time (just clicking Save triggers the errors in the log):
image

@TheWitness
Copy link
Member

Oh, did not notice that.

TheWitness added a commit that referenced this issue Feb 18, 2021
Correcting one more SQL logging issue.
@TheWitness
Copy link
Member

Check again. Fixed.

@nuno-silva
Copy link
Contributor Author

Nice. Thanks!

@netniV netniV changed the title Automation causes SQL syntax errors when invalid Operations are present Automation causes SQL syntax errors when invalid operations are present Apr 30, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 30, 2021
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