Bug report #19531
Running extract by attribute in a model and providing a non-existent selection attribute causes QGIS to crash
|Affected QGIS version:||3.3(master)||Regression?:||Yes|
|Operating System:||Windows 10||Easy fix?:||Yes|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||Yes||Copied to github as #:||27358|
QGIS crashes if you use the "Extract by attribute" algorithm in a model in QGIS processing, and specify a field for the selection attribute which does not exist in the provided layer. A model and sample layer which demonstrates this is attached. This behaviour is only possible in a model (or in batch mode), since the field is populated by a drop-down list when run directly as an algorithm.
The algorithm id is native:extractbyattribute. I think it is a regression because while in 2.18 it would also not give an informative exception (it produces an empty layer), it did not crash QGIS.
I suspect that this bug can be fixed by adding something like:
if (idx == -1) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "FIELD" ) ) );
after https://github.com/qgis/QGIS/blame/master/src/analysis/processing/qgsalgorithmextractbyattribute.cpp#L105, but I haven't been able to test that.