Skip to content

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

@nuno-silva

Description

@nuno-silva

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourresolvedA fixed issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions