Problem/Motivation
When a non existing field key in Conditions is set and we try to access the sensor a fatal error occurs.
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column '%' in 'where clause'
Steps to reproduce:
Go to admin/config/system/monitoring/sensors/add.
Set a label and select Database Aggregator.
Set table as watchdog, any string in Conditions and 'wid' in Verbose fields.
Save.
Go to the link of the created sensor.
Proposed resolution
We should verified that the field key exist in the table.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2557977-6.patch | 1.92 KB | giancarlosotelo |
| #6 | 2557977-TESTONLY.patch | 1.01 KB | giancarlosotelo |
| #2 | 2557977-2.patch | 936 bytes | giancarlosotelo |
Comments
Comment #2
giancarlosotelo commentedAdding a try/catch would solve this problem.
Comment #4
miro_dietikerThe resultVerbose function should not throw an exception.
This situation needs to be caught internally inside the verbose processing. Also we can display a proper error message in such a case - not just verbose message markup.
Comment #5
berdirI'm actually OK with fixing it like this. We do it exactly the same for the actual sensor check too.
Comment #6
giancarlosotelo commentedWell I added test for this error creating a Database Sensor with invalids conditions and asserting that the sensor has no problems otherwise should fail.
Comment #7
LKS90 commentedWorks correctly, I'm just not sure about the test. It'd be nicer if it explicitly failed instead of just producing one exception. (You could do that with another try/catch() block where you call the runSensor() method)
Comment #8
miro_dietikerThe test is fine. It just needs to fail then.
Committed.
Comment #10
giancarlosotelo commentedCan this issue be related to #2528528: Test DatabaseAggregator sensor with invalid fields ?
We are testing DatabaseAggregator with wrong values. or it is more related to UI Test?
Comment #14
juanse254 commentedComment #18
giancarlosotelo commented