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

Some GDAL processing tools raise exceptions if active layer is unavailable #51958

Closed
2 tasks done
kannes opened this issue Feb 21, 2023 · 2 comments · Fixed by #51994
Closed
2 tasks done

Some GDAL processing tools raise exceptions if active layer is unavailable #51958

kannes opened this issue Feb 21, 2023 · 2 comments · Fixed by #51994
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms

Comments

@kannes
Copy link
Contributor

kannes commented Feb 21, 2023

What is the bug or the crash?

Some GDAL processing tools raise exceptions if active layer is unavailable

Steps to reproduce the issue

Set up an unavailable layer, e.g. by moving a referenced file or by breaking WFS access like this:

  1. Go to Options -> Network
  2. Enable Use Proxy for Web Access
  3. Choose HttpProxy or something else where you can specify a proxy
  4. Set the host to localhost and the port to a port where you do not have a proxy running (e.g. 34567 probably)
  5. Add a WFS layer to your QGIS project, e.g. ms:inv80_lgeomorph from http://maps.zh.ch/wfs/FnsNSWFS (random result from web search)

At this stage QGIS should show a warning sign next to the layer in the layer tree. If so, continue:

  1. Try to open a GDAL processing tool like gdal:buffervectors, gdal:dissolve or gdal:ogrinfo (other vector tools did not raise this exception for me).

You will get a yellow "Python error" message and a stack trace like this:

2023-02-21T11:24:04     WARNING    Traceback (most recent call last):
              File "/usr/share/qgis/python/plugins/processing/ProcessingPlugin.py", line 387, in executeAlgorithm
              dlg = alg.createCustomParametersWidget(parent)
              File "/usr/share/qgis/python/plugins/processing/algs/gdal/GdalAlgorithm.py", line 64, in createCustomParametersWidget
              return GdalAlgorithmDialog(self, parent=parent)
              File "/usr/share/qgis/python/plugins/processing/algs/gdal/GdalAlgorithmDialog.py", line 56, in __init__
              self.mainWidget().parametersHaveChanged()
              File "/usr/share/qgis/python/plugins/processing/algs/gdal/GdalAlgorithmDialog.py", line 143, in parametersHaveChanged
              commands = self.algorithm().getConsoleCommands(parameters, context, feedback, executing=False)
              File "/usr/share/qgis/python/plugins/processing/algs/gdal/Buffer.py", line 103, in getConsoleCommands
              raise QgsProcessingException(self.invalidSourceError(parameters, self.INPUT))
             _core.QgsProcessingException: Could not load source layer for INPUT: Geomorphologische_Objekte_Inv__80__faa3c9a6_2825_40d3_ae75_8eec4e96bc92 not found

The tool should fail later or differently, with a user-friendly message, not a traceback. Other tools seem to simply not pre-populate their input comboboxes with this layer.

Versions

QGIS-Version 3.28.3-Firenze QGIS-Codeversion c12bcb2
Qt-Version 5.15.3
Python-Version 3.10.6
GDAL-Version 3.4.1
PROJ-Version 8.2.1
EPSG-Registraturdatenbankversion v10.041 (2021-12-03)
GEOS-Version 3.10.2-CAPI-1.16.0
SQLite-Version 3.37.2
PDAL-Version 2.3.0
PostgreSQL-Client-Version unknown
SpatiaLite-Version 5.0.1
QWT-Version 6.1.4
QScintilla2-Version 2.11.6
BS-Version Ubuntu 22.04.1 LTS
       
Aktive Python-Erweiterungen
Qgis2threejs 2.7.1
QuickOSM 2.1.1
processing 2.12.99
sagaprovider 2.12.99
grassprovider 2.12.99
MetaSearch 0.3.6
db_manager 0.1.20

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

I did not test raster tools similarly.

@kannes kannes added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Feb 21, 2023
@agiudiceandrea agiudiceandrea added the Processing Relating to QGIS Processing framework or individual Processing algorithms label Feb 21, 2023
@agiudiceandrea
Copy link
Contributor

It seems to me the issue doesn't occur on my Windows system with QGIS 3.28.3:

gdalprocessing.mp4

nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Feb 23, 2023
GDAL commands for invalid layers

This is a partial fix, which at least removes the uncaught exception.
Ideally we'd gracefully fall back to using the layer's source
(even if it doesn't exist!) in the generated GDAL commands. But that's
far from trivial to do.

Fixes qgis#51958
nyalldawson added a commit that referenced this issue Feb 23, 2023
GDAL commands for invalid layers

This is a partial fix, which at least removes the uncaught exception.
Ideally we'd gracefully fall back to using the layer's source
(even if it doesn't exist!) in the generated GDAL commands. But that's
far from trivial to do.

Fixes #51958
qgis-bot pushed a commit that referenced this issue Feb 23, 2023
GDAL commands for invalid layers

This is a partial fix, which at least removes the uncaught exception.
Ideally we'd gracefully fall back to using the layer's source
(even if it doesn't exist!) in the generated GDAL commands. But that's
far from trivial to do.

Fixes #51958
nyalldawson added a commit that referenced this issue Feb 27, 2023
GDAL commands for invalid layers

This is a partial fix, which at least removes the uncaught exception.
Ideally we'd gracefully fall back to using the layer's source
(even if it doesn't exist!) in the generated GDAL commands. But that's
far from trivial to do.

Fixes #51958
@kannes
Copy link
Contributor Author

kannes commented Feb 27, 2023

Thanks a lot, @nyalldawson!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
2 participants