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
This commit is contained in:
Tim Burke 2019-08-30 21:40:03 -07:00
parent eed76d8bed
commit c71bb25063
1 changed files with 4 additions and 0 deletions

View File

@ -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