Skip to content

Set workspace to null for remote datasets #14535

Description

@etj

Follow-up to #14524. store is already null for remote datasets. workspace cannot follow the same way yet, because unlike store it is read directly (not only through is_remote_resource()-guarded GeoFence paths) in several places that assume a non-null value.

Line references below are pinned to 246ecde5 on branch 14524_remove.

What is already safe

Every GeoFence-related caller of get_dataset_workspace() is covered by the #14524 fixes:

What blocks nulling it

1. ArcGIS harvester reuses the same workspace variable for both the field value and the alternate string.
See arcgis.py lines 208-209 and 233
(the same pattern repeats at lines 312-313 and 337):
workspace = "remoteWorkspace" feeds both alternate = f"{workspace}:{name}" and "workspace": workspace in the same dict.
Nulling workspace naively turns alternate into "None:<name>".
Needs decoupling: build alternate from a literal, set additional_parameters["workspace"] = None separately.

2. set_style has no remote guard.
resource/manager.py:480
calls self._concrete_resource_manager.set_style(...) unconditionally (gated only on sld_file/sld_uploaded being present on an update call), with no is_remote_resource() check. That reaches geoserver/helpers.py's set_dataset_style() / save_style(), which call
gs_catalog.get_style(name, workspace=saved_dataset.workspace) / create_style(..., workspace=...) against the local GeoServer.

Today workspace="remoteWorkspace" there is harmless: GeoServer has no such workspace, so the lookup just misses. With workspace=None, get_style()/create_style() mean unscoped/global style, which is a real behavior change and could collide with an unrelated global style of the same name.
This gap predates #14524 and should be fixed regardless of the workspace change.

3. Persisted, user-visible link names embed the raw value.
utils.py lines 1530, 1545, 1566:
ogc_wms_name = f"OGC WMS: {instance.workspace} Service" (and the WFS/WCS
equivalents). With workspace=None these become literally "OGC WMS: None Service" on every remote dataset's page. Not a crash, but a visible regression.

4. Dataset.workspace is not nullable today.
layers/models.py:120:
workspace = models.CharField(_("Workspace"), max_length=255), no null=True.
A migration is needed, same shape as layers/migrations/0047_alter_dataset_store.py.

Tasks in scope

  1. Migration: make workspace nullable.
  2. Harvesters (wms.py, arcgis.py x2) and service handlers set workspace: None in their additional_parameters / indexed-dataset fields, decoupling ArcGIS's alternate construction from the field value.
  3. Guard resource/manager.py's set_style dispatch with is_remote_resource().
  4. Fix the three OGC link-name f-strings in utils.py to omit or fall back sensibly when workspace is falsy.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions