Skip to content

Commit

Permalink
Fix ERT crashes if invalid range string in config
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonSohoel committed Oct 28, 2024
1 parent 33c43be commit 06cc6d0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ert/config/gen_data_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,22 @@ def from_config_dict(cls, config_dict: ConfigDict) -> Optional[Self]:
options = option_dict(gen_data, 1)
name = gen_data[0]
res_file = options.get("RESULT_FILE")
report_steps = options.get("REPORT_STEPS", "")

if res_file is None:
raise ConfigValidationError.with_context(
f"Missing or unsupported RESULT_FILE for GEN_DATA key {name!r}",
name,
)
try:
_report_steps: Optional[List[int]] = rangestring_to_list(report_steps)
except ValueError as e:
raise ConfigValidationError.with_context(
f"The REPORT_STEPS setting: {report_steps} is invalid"
' - must be a valid range string: e.g.: "0-1, 4-6, 8"',
gen_data,
) from e

_report_steps: Optional[List[int]] = rangestring_to_list(
options.get("REPORT_STEPS", "")
)
_report_steps = sorted(_report_steps) if _report_steps else None
if os.path.isabs(res_file):
result_file_context = next(
Expand Down

0 comments on commit 06cc6d0

Please sign in to comment.