Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix merge into a custom resolver node that raises an exception #487

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/486.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix merge into a custom resolver node that raises an exception
7 changes: 5 additions & 2 deletions omegaconf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,11 @@ def _resolve_simple_interpolation(
),
)
except Exception as e:
self._format_and_raise(key=inter_key, value=None, cause=e)
assert False
if throw_on_resolution_failure:
self._format_and_raise(key=inter_key, value=None, cause=e)
assert False
else:
return None
else:
if throw_on_resolution_failure:
raise UnsupportedInterpolationType(
Expand Down
14 changes: 14 additions & 0 deletions tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,17 @@ def test_merge_with_error_not_changing_target(c1: Any, c2: Any) -> Any:
with pytest.raises(ValidationError):
c1.merge_with(c2)
assert c1 == backup


def test_into_custom_resolver_that_throws(restore_resolvers: Any) -> None:
def fail() -> None:
raise ValueError()

OmegaConf.register_resolver("fail", fail)

configs = (
{"d": 20, "i": "${fail:}"},
{"i": "zzz"},
)
expected = {"d": 20, "i": "zzz"}
assert OmegaConf.merge(*configs) == expected