Skip to content

Commit fb53548

Browse files
author
Alan Christie
committed
fix: Trap ValueError exceptions during split()
1 parent 4610fb0 commit fb53548

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

operator/handlers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,14 @@ def create(name, namespace, spec, **_):
190190
# The supplied command is a string.
191191
# For now split using Python shlex module - i.e. one that honours quotes.
192192
# i.e. 'echo "Hello, world"' becomes ['echo', 'Hello, world']
193-
command_items = shlex.split(command)
193+
#
194+
# We must protect ourselves from split problems - which must be treated
195+
# as a PermanentError (sc-3437).
196+
try:
197+
command_items = shlex.split(command)
198+
except ValueError as ex:
199+
logging.error("Got ValueError trying to split the command (%s)", command)
200+
raise kopf.PermanentError(f"ValueError ({ex.status})")
194201

195202
# Security options
196203
sc_run_as_user = material.get("securityContext", {}).get(

0 commit comments

Comments
 (0)