diff --git a/src/bindings/python/flux/cli/base.py b/src/bindings/python/flux/cli/base.py index ca41b0492c78..ba387c40304b 100644 --- a/src/bindings/python/flux/cli/base.py +++ b/src/bindings/python/flux/cli/base.py @@ -422,7 +422,10 @@ def update_keyval(self, keyval): value = json.loads(value) except json.decoder.JSONDecodeError: value = str(value) - set_treedict(self.config, key, value) + try: + set_treedict(self.config, key, value) + except TypeError as e: + raise TypeError(f"failed to set {key} to {value}: {e}") return self def update_file(self, path, extension=".toml"): diff --git a/src/bindings/python/flux/job/Jobspec.py b/src/bindings/python/flux/job/Jobspec.py index 4561aa75b26d..c947a35735d5 100644 --- a/src/bindings/python/flux/job/Jobspec.py +++ b/src/bindings/python/flux/job/Jobspec.py @@ -564,7 +564,10 @@ def setattr(self, key, val): if not key.startswith(("user.", "system.")): key = "system." + key key = "attributes." + key - set_treedict(self.jobspec, key, val) + try: + set_treedict(self.jobspec, key, val) + except TypeError as e: + raise TypeError(f"failed to set {key} to {val}: {e}") def setattr_shell_option(self, key, val): """