Incorrect invalid YAML handling in receptionist
Current situation
A malformed YAML workflow causes the receptionist service to generate a stack trace:
jobs:
launchGenerator:
generator: tm.squashtest.org/tm.generator@v1
runs-on:
- linux
with:
squashTMAutomatedServerLogin: tfserver
squashTMAutomatedServerPassword: tfserver
squashTMUrl: http://nightly-mariadb-sqtm.nightly-mariadb:8080
testPlanType: Iteration
testPlanUuid: ae7ae739-5409-45c5-83d4-d4b8f730261d
kind: Workflow
name: Workflow avec generator
namespace: default
(Note the missing metadata:
item between kind:
and name:
.)
The generated log is:
[2024-03-08 11:17:37,063] INFO in eventbus: 127.0.0.1 - - "GET /subscriptions HTTP/1.1" 200 99486 "-" "python-requests/2.31.0"
[2024-03-08 11:17:42,146] ERROR in receptionist: Exception on /workflows [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentf/commons/__init__.py", line 285, in wrapper
return function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentf/core/receptionist.py", line 238, in handle_workflow
workflow = _get_workflow()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentf/core/receptionist.py", line 145, in _get_workflow
return yaml.safe_load(request.data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/__init__.py", line 125, in safe_load
return load(stream, SafeLoader)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/__init__.py", line 81, in load
return loader.get_single_data()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/constructor.py", line 49, in get_single_data
node = self.get_single_node()
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/composer.py", line 36, in get_single_node
document = self.compose_document()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/composer.py", line 55, in compose_document
node = self.compose_node(None, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/composer.py", line 84, in compose_node
node = self.compose_mapping_node(anchor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/composer.py", line 127, in compose_mapping_node
while not self.check_event(MappingEndEvent):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/parser.py", line 98, in check_event
self.current_event = self.state()
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/parser.py", line 428, in parse_block_mapping_key
if self.check_token(KeyToken):
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/scanner.py", line 116, in check_token
self.fetch_more_tokens()
File "/usr/local/lib/python3.12/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens
return self.fetch_value()
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/yaml/scanner.py", line 577, in fetch_value
raise ScannerError(None, None,
yaml.scanner.ScannerError: mapping values are not allowed here
in "<byte string>", line 13, column 9:
name: Workflow avec generator
^