Comment 0 for bug 1954940

Revision history for this message
Rafael Lucas Camargos (rcamargo) wrote : Bootstrap fails to complete due to invalid chars validation

Brief Description
-----------------

Investigation: capabilities is a dict.

controller-0:~$ cat re_.py
import re
import jsonpatch

ALLOWED_CHARS = r"^[a-zA-Z0-9!@#$%^&*()_+\-=\[\]{};:\'\"|,.<>\/? ]*$"

patch = [{'op': 'replace', 'path': '/system_mode', 'value': 'simplex'}, {'op': 'replace', 'path': '/capabilities', 'value': {'region_config': False, 'vswitch_type': 'none', 'shared_services': '[]', 'sdn_enabled': False, 'https_enabled': False}}, {'op': 'replace', 'path': '/timezone', 'value': 'UTC'}, {'op': 'replace', 'path': '/region_name', 'value': 'RegionOne'}, {'op': 'replace', 'path': '/service_project_name', 'value': 'services'}, {'op': 'replace', 'path': '/distributed_cloud_role', 'value': None}, {'op': 'replace', 'path': '/system_type', 'value': 'All-in-one'}]

#patch = [{u'path': u'/system_mode', u'value': u'simplex', u'op': u'replace'}, {u'path': u'/region_name', u'value': u'RegionOne', u'op': u'replace'}, {u'path': u'/service_project_name', u'value': u'services', u'op': u'replace'}, {u'path': u'/distributed_cloud_role', u'value': None, u'op': u'replace'}, {u'path': u'/capabilities', u'value': {u'https_enabled': False, u'vswitch_type': u'none', u'region_config': False, u'sdn_enabled': False, u'shared_services': u'[]'}, u'op': u'replace'}, {u'path': u'/system_type', u'value': u'All-in-one', u'op': u'replace'}, {u'path': u'/timezone', u'value': u'UTC', u'op': u'replace'}]

for p in jsonpatch.JsonPatch(patch):

    print(p['value'])
    if p['value'] is not None:
        re.match(ALLOWED_CHARS, p['value'])
controller-0:~$ python2 re_.py
simplex
{'https_enabled': False, 'vswitch_type': 'none', 'region_config': False, 'sdn_enabled': False, 'shared_services': '[]'}
Traceback (most recent call last):

  File "re_.py", line 13, in <module>
    re.match(ALLOWED_CHARS, p['value'])
  File "/usr/lib64/python2.7/re.py", line 137, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or buffer

Severity
--------
N/A

Steps to Reproduce
------------------
N/A

Expected Behavior
------------------
Boostrap should complete

Actual Behavior
----------------
N/A

Reproducibility
---------------
N/A

System Configuration
--------------------
N/A

Branch/Pull Time/Commit
-----------------------
N/A

Last Pass
---------
N/A

Timestamp/Logs
--------------

sysinv 2021-12-15 13:59:36.237 64179 ERROR wsme.api [-] Server-side error: "expected string or bytes-like object". Detail:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/wsmeext/pecan.py", line 84, in callfunction
result = f(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/sysinv/api/controllers/v1/system.py", line 415, in patch
if p['value'] is not None and not re.match(ALLOWED_CHARS, p['value']):
File "/usr/lib/python3.9/re.py", line 191, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object

Test Activity
-------------
Feature Testing

Workaround
----------
N/A