-
-
Notifications
You must be signed in to change notification settings - Fork 180
Open
Labels
Description
The problem
The method checks if value has a params attribute but doesn't verify that params is actually dict-like. If someone passes an object with a params attribute that isn't a dict, you get a confusing AttributeError instead of a clear error message.
Current code:
if not hasattr(value, "params"):
raise TypeError("Value must be URI or BINARY.")
value_type = value.params.get("VALUE", "").upper()
What happens: If value.params
exists but has no .get()
method, this crashes with AttributeError. Users get a confusing error instead of knowing their params object is malformed.
The fix
Wrap the params access in try-catch:
if not hasattr(value, "params"):
raise TypeError("Value must be URI or BINARY.")
try:
value_type = value.params.get("VALUE", "").upper()
except (AttributeError, TypeError):
raise TypeError("Value must have valid params attribute.")
Now users get a clear error message when params is broken.
Testing needed
- Value with no params attribute (already works)
- Value with params that isn't dict-like (currently breaks)
- Value with valid params (no regression)
From: #877 (comment)