Skip to content

QGIS does not request default style for WMS layer when in group/container #63754

@joey-geoloog

Description

@joey-geoloog

What is the bug or the crash?

When adding a WMS layer from a group layer where no styling has been specified, QGIS should request the default style however does not appear to correctly handle the style at all. The layer itself has two styles (one from the group and one from the layer itself) both of which resolve to valid legend graphics.

Image

ArcGIS Pro, for example, handles this by sending a empty &STYLES= parameter. This is conform OGC specification

Image Image

All three of these requests return a valid legend graphic
http://dev-geoserver.gdnnet.lan/geoserver/nlog/ows?service=WMS&version=1.3.0&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=gdw_ng_licence_salt_utm&style=
http://dev-geoserver.gdnnet.lan/geoserver/nlog/ows?service=WMS&version=1.3.0&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=gdw_ng_licence_salt_utm&style=default-style-lic
http://dev-geoserver.gdnnet.lan/geoserver/nlog/ows?service=WMS&version=1.3.0&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=gdw_ng_licence_salt_utm&style=licence_salt

I can confirm that if all other styles are removed, and only one style remains (default-style-) then QGIS handles it properly, so this indeed appears to be applications-side

Image Image

Steps to reproduce the issue

  1. Add a WMS group layer child into QGIS without selecting a style, e.g. drag from Browser to Layers
  2. Layer will be added without style, and results in no legend being added
Image
  1. Add the same layer via Layer>Vector>Add WMS/WMTS and select either style and it will be processed correctly, but the top level layer remains without a legend.
Image

Versions

QGIS version3.40.10-Bratislava
QGIS code revisionc98da2e682
 
Libraries
Qt version5.15.13
Python version3.12.11
GDAL version3.11.3 — Eganville
PROJ version9.6.2
EPSG Registry database versionv12.013 (2025-05-26)
GEOS version3.13.1-CAPI-1.19.2
SQLite version3.50.4
PDAL version2.9.0
PostgreSQL client versionunknown
SpatiaLite version5.1.0
QWT version6.3.0
QScintilla2 version2.14.1
OS versionWindows 11 Version 2009
 
Active Python plugins
pdokservicesplugin5.2.0
slyr_community6.0.0
db_manager0.1.20
MetaSearch0.3.6
processing2.12.99

Supported QGIS version

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

New profile

Additional context

The data is being pulled from GeoServer v2.27.1

ArcGIS Pro version for comparison is 3.2.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugEither a bug report, or a bug fix. Let's hope for the latter!WMS data provider

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions