From c71bb2506310438b011818a44449daea500863fd Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 30 Aug 2019 21:40:03 -0700 Subject: [PATCH] diskfile: Add some argument validation Either all or none of account, container, and object should be provided. If we get some but not all, that's indicating some kind of a coding bug; there's a chance it may be benign, but it seems safer to fail early and loudly. Change-Id: Ia9a0ac28bde4b5dcbf6e979c131e61297577c120 Related-Change: Ic2e29474505426dea77e178bf94d891f150d851b --- swift/obj/diskfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swift/obj/diskfile.py b/swift/obj/diskfile.py index bddde6af84..abf6d03629 100644 --- a/swift/obj/diskfile.py +++ b/swift/obj/diskfile.py @@ -2231,6 +2231,10 @@ class BaseDiskFile(object): self._account = account self._container = container self._obj = obj + elif account or container or obj: + raise ValueError( + 'Received a/c/o args %r, %r, and %r. Either none or all must ' + 'be provided.' % (account, container, obj)) else: # gets populated when we read the metadata self._name = None