qgis / qwc2-demo-app

QWC2 demo application
Other
243 stars 155 forks source link

Bad default value in qwc-config-generator source code #442

Closed naub1n closed 1 year ago

naub1n commented 1 year ago

hi,

Default value for "items" is not a dict but a list according tenantConfig schema.

https://github.com/qwc-services/qwc-config-generator/blob/7c2819d19fdcbd95e11263348d08399f4502f88d/config_generator/config_generator.py#L655

items = themes_config.get("themes", {}).get(
            "items", {})

replace by

items = themes_config.get("themes", {}).get(
            "items", [])

When I only define an empty themes in my tenantConfig like this:

"themesConfig": {
        "themes": {}
      }

config-generator-service crash:

Traceback (most recent call last):
  File "/srv/qwc_service/./server.py", line 53, in generate_configs
    generator = config_generator(tenant)
  File "/srv/qwc_service/./server.py", line 42, in config_generator
    return ConfigGenerator(config, app.logger)
  File "/srv/qwc_service/./config_generator/config_generator.py", line 184, in __init__
    self.search_qgs_projects(generator_config, themes_config)
  File "/srv/qwc_service/./config_generator/config_generator.py", line 729, in search_qgs_projects
    items.append(item)
AttributeError: 'dict' object has no attribute 'append'

But when I add an empty list in "items" object:

"themesConfig": {
        "themes": {
          "items": []
        }
      }

config-generator-service doesn't crash.

manisandro commented 1 year ago

Thanks, fixed in qwc-config-generator v2023.04.23