Skip to content

Support JSON values via env-vars for plugins enabled by default #34

Description

@shai-ikko

When using docker compose as shown in https://orthanc.uclouvain.be/book/users/docker-orthancteam.html, one easy way to configure the container is by setting environment variables. The documentation even gives examples of plugins configured by environment vars with JSON values, set in docker-compose.yml using a syntax such as

       # ...
       environment:
            # ...
            ORTHANC__WORKLISTS: |
                {
                    "Enable": true,
                    "FilterIssuerAet": false,
                    "SaveInOrthancDatabase": true
                }

This works for most plugins, but fails for plugins enabled by default like OE2, because configurator.py tries to merge the configuration with the default, before parsing the JSON. As a result, if you set ORTHANC__ORTHANC_EXPLORER2 to a JSON value, you get an exception in the container startup:

Traceback (most recent call last):
  File "/startup/generateConfiguration.py", line 72, in <module>
    configurator.mergeConfigFromDefaults(moveSoFiles=True)
  File "/startup/configurator.py", line 182, in mergeConfigFromDefaults
    self._mergeConfigFromDefaults(pluginDefaultConfig, pluginName)
  File "/startup/configurator.py", line 157, in _mergeConfigFromDefaults
    self.configuration = self._mergeConfigs(first=self.configuration, second=config, secondSource="defaults:" + defaultsGroup, jsonPath=JsonPath(), overwrite=False)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/startup/configurator.py", line 130, in _mergeConfigs
    self._mergeConfigs(first[k], second[k], secondSource, keyPath, overwrite)
  File "/startup/configurator.py", line 144, in _mergeConfigs
    first[k] = v
    ~~~~~^^^
TypeError: 'str' object does not support item assignment

The image in question is the current orthancteam/orthanc; I can only see the tag "latest" but it says

"Created": "2025-12-15T10:04:38.367049234Z",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions