Skip to content

Commit f0d389b

Browse files
committed
fix: restore path validation in PathData.set_value
- Add back path validation to ensure value.path matches PathData.path - Add error logging for path mismatch - Update docstring to document ValueError - Improve code organization with proper error handling This ensures data consistency by preventing values with mismatched paths from being added to a PathData instance.
1 parent b76a690 commit f0d389b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

helm_values_manager/models/path_data.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@ def set_value(self, environment: str, value: Value) -> None:
6060
Args:
6161
environment (str): The environment to set the value for
6262
value (Value): The Value object to set
63+
64+
Raises:
65+
ValueError: If the Value object's path doesn't match this PathData's path
6366
"""
6467
logger.debug("Setting value for path %s in environment %s", self.path, environment)
68+
69+
if value.path != self.path:
70+
logger.error("Value path %s doesn't match PathData path %s", value.path, self.path)
71+
raise ValueError(f"Value path {value.path} doesn't match PathData path {self.path}")
72+
6573
self._values[environment] = value
6674

6775
def get_value(self, environment: str, resolve: bool = False) -> Optional[str]:

0 commit comments

Comments
 (0)