]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: improve error handling when _customize_resource is wrong
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 30 Jun 2025 21:46:10 +0000 (17:46 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 12 Aug 2025 14:24:49 +0000 (10:24 -0400)
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 <jmulligan@redhat.com>
src/pybind/mgr/smb/resourcelib.py

index 7c76660015a7b627dff74e67cbe4c0e307110425..7128dba2673769173502b1fdf1981ff23a6c468a 100644 (file)
@@ -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