GeoCat / qgis-bridge-plugin

GeoCat Bridge is a plugin for QGIS that can be used to publish geospatial (meta)data to the cloud.
https://geocat.github.io/qgis-bridge-plugin/
GNU General Public License v3.0
35 stars 17 forks source link

Can't list or add a datastore for Geoserver #191

Open rfazimut opened 1 week ago

rfazimut commented 1 week ago

Describe the bug With the current version, from the connection tab, I cannot add a database or iterate the list of database defined on the geoserver with this message:

File "C:\Users/rfortin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geocatbridge\servers\views\geoserver.py", line 184, in _addGeoserverPgDatastores datastores = list(chain.from_iterable(worker_result)) TypeError: 'KeyError' object is not iterable

To Reproduce Steps to reproduce the behavior:

  1. Add connection Geoserver
  2. Specify parameter and credential
  3. Select File-based...
  4. Test Connection == OK
  5. Change storage to Import into PostGIS database (managed by GeoServer)
    Datastore are defined on the server
  6. CLick Add datastore
  7. Specifiy parameter
  8. Click OK
  9. The error message shows.

Expected behavior Datastore is added or listed from the Geoserver

Screenshots If applicable, add screenshots to help explain your problem.

Environment info (please complete the following information): Bridge version: GeoCat Bridge 4.5.1 for QGIS 3.16+ QGIS version: 3.22.5-Białowieża (rev c2723178) OS version: Windows 10 10.0.19045 Python version: 3.9.5 (rev 0a7dcbd)

Additional context GeoServer 2.26

GeoSander commented 1 week ago

Thanks for reporting @rfazimut.

Three additional questions I have:

  1. If there already is a PostGIS datastore on GeoServer (defined manually perhaps using the GS web UI - not using Bridge), and you select Import into PostGIS database (managed by GeoServer) (so at step 5 above), can you at least confirm that the combobox below it gets populated with some existing datastores?

  2. Which parameters (at step 7) do you specify? I don't mean the exact values (user, pass, etc.) but I would like to know which fields you are setting.

  3. After step 8 (OK), does the "Add datastore" dialog close first before the error appears?

Thanks, Sander

rfazimut commented 1 week ago

Hi!

Answer to your questions :

  1. Yes. There are defined datastore on the Geoserver. The error come as soon as we select select Import into PostGIS database (managed by GeoServer)

  2. Here an example @.***

  3. Yes. It tries to refresh the list of datastore and we get the same error.

I tried also using the other option (direct connect) after a connection to the same PostGIS database as been defined. In this case, we get a different message when we try to publish.

Errors: Traceback (most recent call last): File "C:\Users/rfortin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geocatbridge\publish\tasks.py", line 129, in run _publish(layer, publish_fields) File "C:\Users/rfortin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geocatbridge\publish\tasks.py", line 65, in _publish self.geodata_server.publishLayer(lyr, pub_fields) File "C:\Users/rfortin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geocatbridge\servers\models\geoserver.py", line 277, in publishLayer self._publishVectorLayerFromPostgis(layer, db, fields) File "C:\Users/rfortin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geocatbridge\servers\models\geoserver.py", line 669, in _publishVectorLayerFromPostgis self.request(ds_url, data=ds, method="post") File "C:\Users/rfortin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geocatbridge\servers\bases.py", line 279, in request result.raise_for_status() File "C:\PROGRA~1\QGIS32~1.5\apps\Python39\lib\site-packages\requests\models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 500 Server Error: Server Error for url: http://192.168.10.207:8080/geoserver/rest/workspaces/evalzonage49048/datastores

At this point, we have been unable to publish layer to Geoserver other then using the geopackage option.

It is not clear to me if checking the option “Reference existing PostGIS tables (if exists)” will actually just publish the layer and not copy the data which is already there. Is that what it is supposed to do?

Robert

GeoSander commented 1 week ago

Thanks for the info @rfazimut.

Besides the fact that this is not supposed to happen and we need to fix the user experience (in case there is an error accessing/listing the datastore), there also seems to be something peculiar about your datastore(s).

Since you get a 500 when using the Direct Connect approach, could you perhaps share the error that GeoServer throws (see GeoServer logs in web UI)?

Concerning the Reference existing PostGIS tables (if possible) option, you can right-click on it to get more info as to what that does:

image

That option will only work if:

In that case it will work the way you thought it would.