Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: reclass should support empty string keynames #1171

Open
gburiola opened this issue Apr 16, 2024 · 0 comments
Open

[bug]: reclass should support empty string keynames #1171

gburiola opened this issue Apr 16, 2024 · 0 comments
Labels

Comments

@gburiola
Copy link
Contributor

Description of the bug

If you use an empty string '' as a keyname inside the inventory, reclass fails. Example:

$ cat inventory/targets/my_target.yml 
classes: []
parameters:
  target_name: my_target
  '': INFO

That is valid YAML and also used by some application configs. Example:
https://docs.ververica.com/vvp/user-guide/application-operations/session-clusters/logging#loggers

Steps to reproduce

### kapitan / reclass error


$ kapitan inventory

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/storage/memcache_proxy.py", line 41, in get_node
    return self._nodes_cache[name]
KeyError: 'my_target'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.8/site-packages/kapitan/resources.py", line 290, in generate_inventory
    inv = inventory_reclass(args.inventory_path)
  File "/opt/venv/lib/python3.8/site-packages/kapitan/resources.py", line 361, in inventory_reclass
    cached.inv = _reclass.inventory()
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/core.py", line 261, in inventory
    inventory = self._get_inventory(True, '', None)
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/core.py", line 187, in _get_inventory
    node_base = self._storage.get_node(nodename, self._settings)
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/storage/memcache_proxy.py", line 43, in get_node
    ret = self._real_storage.get_node(name, settings)
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/storage/yaml_fs/__init__.py", line 103, in get_node
    entity = YamlData.from_file(path).get_entity(name, pathname, settings)
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/storage/yamldata.py", line 98, in get_entity
    parameters = datatypes.Parameters(parameters, settings, self._uri)
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/datatypes/parameters.py", line 67, in __init__
    self.merge(mapping)
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/datatypes/parameters.py", line 241, in merge
    self._base = self._merge_recurse(self._base, wrapped)
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/datatypes/parameters.py", line 210, in _merge_recurse
    return self._merge_dict(cur, new)
  File "/opt/venv/lib/python3.8/site-packages/kapitan/reclass/reclass/datatypes/parameters.py", line 174, in _merge_dict
    if key[0] in self._settings.dict_key_prefixes:
IndexError: string index out of range


### What happened?

error above

### Additional context

_No response_

### Version (kapitan)

v0.31.0 (stable)

### Version (kapitan)

I use kapitan directly (pip, docker)

### Python virtual environment

- [ ] pyenv
- [ ] venv
- [ ] no environment

### OS information

_No response_

### Relevant log output

_No response_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant