Skip to content

Commit 7eb8a67

Browse files
committed
revert: re-add root schema validation under validate
1 parent 0e15b4b commit 7eb8a67

File tree

1 file changed

+6
-2
lines changed
  • aws_lambda_powertools/utilities/feature_flags

1 file changed

+6
-2
lines changed

aws_lambda_powertools/utilities/feature_flags/schema.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ class SchemaValidator:
2828
def __init__(self, schema: Dict[str, Any]):
2929
self.schema = schema
3030

31-
if not isinstance(self.schema, dict):
32-
raise ConfigurationError(f"Schema must be a dictionary, schema={str(self.schema)}")
31+
@staticmethod
32+
def _is_dict_and_non_empty(value: Optional[Dict]):
33+
return not value or not isinstance(value, dict)
3334

3435
@staticmethod
3536
def _validate_condition(rule_name: str, condition: Dict[str, str]) -> None:
@@ -88,6 +89,9 @@ def _validate_feature(self, name: str, feature: Dict[str, Any]) -> None:
8889
self._validate_rule(name, rule)
8990

9091
def validate(self) -> None:
92+
if self._is_dict_and_non_empty(self.schema):
93+
raise ConfigurationError(f"Schema must be a dictionary, schema={str(self.schema)}")
94+
9195
features: Optional[Dict[str, Dict]] = self.schema.get(FEATURES_KEY)
9296
if not isinstance(features, dict):
9397
raise ConfigurationError(f"'features' key must be present, schema={self.schema}")

0 commit comments

Comments
 (0)