You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tried to validate a mapping key with a regex but the mapping key is an integer.
If there is a better way to do this let me know. I think you should either quote the keys, or as you are trying to regex them, stringify them before regexing
Traceback (most recent call last):
File "/home/terry/.virtualenv/ecs_v2/bin/pykwalify", line 10, in <module>
sys.exit(cli_entrypoint())
File "/home/terry/.virtualenv/ecs_v2/lib/python3.8/site-packages/pykwalify/cli.py", line 95, in cli_entrypoint
run(parse_cli())
File "/home/terry/.virtualenv/ecs_v2/lib/python3.8/site-packages/pykwalify/cli.py", line 82, in run
c.validate()
File "/home/terry/.virtualenv/ecs_v2/lib/python3.8/site-packages/pykwalify/core.py", line 155, in validate
self._start_validate(self.source)
File "/home/terry/.virtualenv/ecs_v2/lib/python3.8/site-packages/pykwalify/core.py", line 202, in _start_validate
self._validate(value, root_rule, path, done)
File "/home/terry/.virtualenv/ecs_v2/lib/python3.8/site-packages/pykwalify/core.py", line 236, in _validate
self._validate_mapping(value, rule, path, done=None)
File "/home/terry/.virtualenv/ecs_v2/lib/python3.8/site-packages/pykwalify/core.py", line 570, in _validate_mapping
self._validate(v, r, u"{0}/{1}".format(path, k), done)
File "/home/terry/.virtualenv/ecs_v2/lib/python3.8/site-packages/pykwalify/core.py", line 236, in _validate
self._validate_mapping(value, rule, path, done=None)
File "/home/terry/.virtualenv/ecs_v2/lib/python3.8/site-packages/pykwalify/core.py", line 544, in _validate_mapping
is_present = any([re.search(required_regex, v) for v in value])
File "/home/terry/.virtualenv/ecs_v2/lib/python3.8/site-packages/pykwalify/core.py", line 544, in <listcomp>
is_present = any([re.search(required_regex, v) for v in value])
File "/usr/local/lib/python3.8/re.py", line 199, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
Environment
Tried to validate a mapping key with a regex but the mapping key is an integer.
If there is a better way to do this let me know. I think you should either quote the keys, or as you are trying to regex them, stringify them before regexing
Steps to Reproduce
Schema
Data
Expected Behavior
Validation passed
Observed Behavior
Got exception
Is because the list comprehension here https://github.com/Grokzen/pykwalify/blob/master/pykwalify/core.py#L578 - is trying to run a regex search on a non-string value.
Could be fixed by stringifying the value inside the list comp
I can make a PR if your happy with this solution
The text was updated successfully, but these errors were encountered: