keras-team/keras
[Bug] deserialize_keras_object raises AttributeError for invalid config types
Chiusa
#22.701 aperta il 18 apr 2026
Good first issuebackend:tensorflowstat:contributions welcometype:Bug
Metriche repository
- Star
- (64.232 stelle)
- Metriche merge PR
- (Merge medio 6g 23h) (75 PR mergiate in 30 g)
Descrizione
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.