Page MenuHomeSoftware Heritage

swh-fuse: fails with "'TypeError: Cannot merge a <class 'dict'> with a <class 'NoneType'>" when conffile is empty or commented out
Closed, MigratedEdits Locked


When ~/.config/swh/global.yml is either empty or entirely commented out (with # lines), swh fuse mount fails with the following type error:

Traceback (most recent call last):
  File "/home/zack/.virtualenvs/swh/bin/swh", line 33, in <module>
    sys.exit(load_entry_point('swh.core', 'console_scripts', 'swh')())
  File "/home/zack/dati/projects/sw-heritage/git/swh-environment/swh-core/swh/core/cli/", line 135, in main
    return swh(auto_envvar_prefix="SWH")
  File "/home/zack/.virtualenvs/swh/lib/python3.8/site-packages/click/", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/zack/.virtualenvs/swh/lib/python3.8/site-packages/click/", line 782, in main
    rv = self.invoke(ctx)
  File "/home/zack/.virtualenvs/swh/lib/python3.8/site-packages/click/", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/zack/.virtualenvs/swh/lib/python3.8/site-packages/click/", line 1256, in invoke
    Command.invoke(self, ctx)
  File "/home/zack/.virtualenvs/swh/lib/python3.8/site-packages/click/", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/zack/.virtualenvs/swh/lib/python3.8/site-packages/click/", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/zack/.virtualenvs/swh/lib/python3.8/site-packages/click/", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/zack/dati/projects/sw-heritage/git/swh-environment/swh-fuse/swh/fuse/", line 67, in fuse
    conf = config.merge_configs(DEFAULT_CONFIG, conf)
  File "/home/zack/dati/projects/sw-heritage/git/swh-environment/swh-core/swh/core/", line 224, in merge_configs
    raise TypeError("Cannot merge a %s with a %s" % (type(base), type(other)))
TypeError: Cannot merge a <class 'dict'> with a <class 'NoneType'>

that is unfortunate, given one of the main interests of YAML for configuration files is the ability to comment out stuff (and an empty configuration file is an entirely legitimate thing as well).

Event Timeline

zack triaged this task as Normal priority.Oct 18 2020, 1:53 PM
zack created this task.

The configuration parsing/merging is currently done using swh.core.config and should be changed with T1410.

zack lowered the priority of this task from Normal to Low.Nov 20 2020, 2:50 PM

It seems like this is no longer the case, I tried both empty or non-existent file and I now get this error message:

WARNING:root:Using default configuration (cannot load custom one)
Traceback (most recent call last):
  File "/home/haltode/work/swh/swh-environment/swh-fuse/swh/fuse/", line 72, in fuse
    raise ValueError(f"Cannot parse configuration file: {config_file}")
ValueError: Cannot parse configuration file: /home/haltode/.config/swh/global.yml

And swh-fuse does not crash.