From a9d1a488bba86aa08257b4b460a8cb4fc888fca0 Mon Sep 17 00:00:00 2001 From: Shweta Bhosale Date: Wed, 11 Dec 2024 13:07:15 +0530 Subject: [PATCH] mgr/cephadm: mgr orchestrator module raise exception if there is trailing tab in yaml file Fixes: https://tracker.ceph.com/issues/69192 Signed-off-by: Shweta Bhosale (cherry picked from commit dfa632b42558278d26cabb88248aa7ae8ba8fcfc) --- src/pybind/mgr/orchestrator/module.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index cde6448b3c0ee..9bb56ae15a19b 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -1548,7 +1548,13 @@ Usage: specs: List[Union[ServiceSpec, HostSpec]] = [] # YAML '---' document separator with no content generates # None entries in the output. Let's skip them silently. - content = [o for o in yaml_objs if o is not None] + try: + content = [o for o in yaml_objs if o is not None] + except yaml.scanner.ScannerError as e: + msg = f"Invalid YAML received : {str(e)}" + self.log.exception(msg) + return HandleCommandResult(-errno.EINVAL, stderr=msg) + for s in content: spec = json_to_generic_spec(s) @@ -1939,7 +1945,13 @@ Usage: specs: List[TunedProfileSpec] = [] # YAML '---' document separator with no content generates # None entries in the output. Let's skip them silently. - content = [o for o in yaml_objs if o is not None] + try: + content = [o for o in yaml_objs if o is not None] + except yaml.scanner.ScannerError as e: + msg = f"Invalid YAML received : {str(e)}" + self.log.exception(msg) + return HandleCommandResult(-errno.EINVAL, stderr=msg) + for spec in content: specs.append(TunedProfileSpec.from_json(spec)) else: -- 2.39.5