]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
orchestra/run: better handle weird args 2024/head
authorKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Thu, 30 Jan 2025 11:18:24 +0000 (12:18 +0100)
committerKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Thu, 30 Jan 2025 12:53:31 +0000 (13:53 +0100)
If one of the command args in remote.run is None then there is exception
occurs while trying to qoute argument list:

   TypeError: expected string or bytes-like object

This fix addresses the issue and gives user better idea what is
happening, and how to fix the error.

Fixes: https://tracker.ceph.com/issues/64452
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@clyso.com>
teuthology/orchestra/run.py

index bf6a0695332f66ffedba03bc0d4fbeeb32cf8f53..7f6fdb2407a6921c59f85d390b15b2321461f03a 100644 (file)
@@ -242,15 +242,21 @@ class Raw(object):
 
 def quote(args):
     """
-    Internal quote wrapper.
+    Internal quote wrapper. None arguments are not allowed.
+
+    :param args: list of str or Raw objects
+
+    :raises: :class:`RuntimeError`: if one of the args is None.
     """
     def _quote(args):
         """
         Handle quoted string, testing for raw charaters.
         """
-        for a in args:
+        for i, a in enumerate(args):
             if isinstance(a, Raw):
                 yield a.value
+            elif a is None:
+                raise RuntimeError(f"Argument at position {i} is None: {args}")
             else:
                 yield shlex.quote(a)
     if isinstance(args, list):