Bug report #19531

Running extract by attribute in a model and providing a non-existent selection attribute causes QGIS to crash

Added by Rudi von Staden about 2 years ago. Updated about 2 years ago.

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.

extract_by_attribute.zip (719 KB) Rudi von Staden, 2018-08-02 11:37 AM

Associated revisions

Revision 4acef1ef
Added by Nyall Dawson about 2 years ago

[processing] Fix crash in extract by attribute when field name does not exist

Fixes #19531


#1 Updated by Nyall Dawson about 2 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Also available in: Atom PDF