keras-team/keras
View on GitHub[Bug] deserialize_keras_object raises AttributeError for invalid config types
Open
#22701 opened on Apr 18, 2026
Good first issuebackend:tensorflowstat:contributions welcometype:Bug
Description
Description
deserialize_keras_object may raise AttributeError when provided with invalid config types (e.g., list or string), indicating that input validation occurs after internal method calls.
Reproduction Script
import os
os.environ["KERAS_BACKEND"] = "tensorflow"
from keras.saving import deserialize_keras_object
config = {
"class_name": "Dense",
"module": "keras.layers",
"config": [1, 2, 3] # invalid type
}
try:
deserialize_keras_object(config)
except Exception as e:
print("Exception type:", type(e).__name__)
print("Message:", e)
Observed behavior
- Raises
AttributeError: 'list' object has no attribute 'get'
Expected behavior
- Should raise a clear
ValueErrororTypeErrorfor invalid input structure
Notes
This suggests input validation happens too late and exposes internal implementation details.