From: John Mulligan Date: Mon, 30 Jun 2025 21:46:10 +0000 (-0400) Subject: mgr/smb: improve error handling when _customize_resource is wrong X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=917609b23fa99c34d4734dd44b07e112caeb5b66;p=ceph.git mgr/smb: improve error handling when _customize_resource is wrong While working on other changes I noticed that if _customize_resource does not return a resource object (something fairly easy to do like accidentally delete a line) the error it produces is somewhat hard to debug. Check the return from the function returns a non-false object to provide better error reporting. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/smb/resourcelib.py b/src/pybind/mgr/smb/resourcelib.py index 7c76660015a7b..7128dba267376 100644 --- a/src/pybind/mgr/smb/resourcelib.py +++ b/src/pybind/mgr/smb/resourcelib.py @@ -507,6 +507,11 @@ class Resource: _customize = getattr(resource_cls, '_customize_resource', None) if _customize is not None: resource = _customize(resource) + if not resource: + raise ValueError( + '_customize_resource must return a valid resource object,' + f' not {resource!r}' + ) return resource