• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

omry / omegaconf
100%
master: 100%

Build:
Build:
LAST BUILD BRANCH: main
DEFAULT BRANCH: master
Repo Added 03 Sep 2018 08:45PM UTC
Files 19
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

LAST BUILD ON BRANCH main
branch: SELECT
CHANGE BRANCH
x
  • No branch selected
  • #174
  • 1.4.0
  • 1.4.0_branch
  • 1.4_branch
  • 127
  • 164
  • 184
  • 185
  • 2.0.0.rc3
  • 2.0.0rc3
  • 2.0.0rc4
  • 2.0.0rc5
  • 2.0.0rc6
  • 2.0.1
  • 2.0.4
  • 2.0_branch
  • 2.1.0
  • 2.1.0.rc1
  • 2.1_branch
  • 2.2_branch
  • 2.3_branch
  • 2.4_branch
  • 241
  • 246
  • 253
  • 260
  • 304-setdefault
  • 305-missing-list-merge
  • 336-list-merge-none-error
  • 343
  • 350
  • 363
  • 37
  • 39
  • 418
  • 425
  • 442
  • 461-flags-root
  • 461_annotated_dicts_are_open
  • 481-feedback
  • 541-oc.select
  • 589-nested-flag-override
  • 601-list-copy
  • 601-update
  • 67
  • 674-select-with-default
  • 697
  • 7iW-merge-dont-overwrite-structured-value
  • EnumNode.__eq__
  • Jasha10-patch-1
  • _get_node_throw_on_missing
  • allow_non_primitive
  • allow_objects_failure_case
  • allow_objects_with_non_copyable
  • antlr
  • arisliang-master
  • attribute_error
  • auto-expand
  • benchmark_and_fixes
  • bugpass
  • bye_27
  • code_config
  • commit_hook
  • compact
  • contains
  • copy
  • coverage
  • create
  • create_bug
  • dc
  • debug
  • del
  • deprecated
  • deprecated_auto_expand
  • detect-interpolation-cycles
  • dict-fixes
  • docs
  • docs2
  • dotlist
  • double_error
  • ducks
  • ec.env-default-non-str
  • empty-file
  • enum
  • enum_str
  • env
  • eq
  • error_msg_on_non_structured_config
  • error_newline
  • errors
  • exception
  • fix-ci-coverage
  • fix_examples
  • fixes
  • flags_override
  • frozen
  • i945
  • improve-error-actionability
  • in
  • indirect_interpolation
  • inter-tests
  • interpolation_missing
  • interpolation_missing_merge
  • interpolation_with_@
  • is_missing
  • isort
  • isort5
  • items()
  • jasha-fix-readthedocs-build-os
  • list-iter
  • list_in
  • list_iter3
  • list_iterate
  • literal
  • main
  • mask
  • master
  • merge_allow_objects
  • merge_element_type
  • merge_into_custom_resolver
  • merge_into_missing_dict
  • merge_into_none_list_backport
  • merged_type
  • minor
  • misc
  • missing
  • missing-not-overrwriting
  • missing_bug
  • missing_literal
  • news
  • no_pickle_flags_cache
  • non-primitive-pass2
  • oc.deprecated
  • omry-patch-1
  • open_dict_bug
  • parent_bug
  • pc
  • pickle-bc
  • pop
  • pr1244
  • pr1245
  • pr1246
  • pr1247
  • pr1248
  • pr1249
  • pr1250
  • pr1252
  • pr1253
  • pr1254
  • pr1257
  • pr1258
  • pr1259
  • pr1260
  • pr1262
  • pr1264
  • pr1265
  • pr1268
  • pr1269
  • pr1270
  • pr1272
  • pr1273
  • pr1277
  • pr1278
  • pr1279
  • pr1281
  • pr1283
  • pr1284
  • pr1285
  • pr1286
  • pr1287
  • pr1289
  • pre-commit
  • pretty_deprecation
  • py.typed
  • py3.13
  • pydev-plugin
  • pytest_mypy
  • python-compat
  • pyyaml-dep
  • rc28
  • readonly-merge
  • ref_type_3
  • refactor-resolvers
  • relative
  • relative-inter-doc
  • relative_fix
  • remove-deprecated
  • remove_dot_warning
  • resolve_updates
  • revert
  • revert-154-merged_type
  • rsokl/deployment
  • sapling-pr-archive-omry
  • sc_ref_type_clean
  • select
  • select_nested_is_relative
  • select_relative
  • serialize-doc
  • sort_keys
  • str_inter_with_ro_parent
  • struct
  • struct_assign
  • struct_del_pop
  • structured-assignment
  • structured_bugs
  • structured_missing
  • subclass_assignment
  • sync_news_readme_2.2
  • test_dict_re_assign_value
  • test_imports
  • to_container
  • to_container_2
  • to_primitive_container
  • tuple
  • type_hints
  • type_str
  • typed_dict
  • types
  • union_error
  • unsafe_merge
  • update
  • update-merge
  • update_force_add
  • val_error_msg
  • warn_dot
  • warning
  • wtf

01 May 2026 08:44PM UTC coverage: 100.0%. Remained the same
07bca34b-cfd3-4349-a256-b0f3299ac536

push

circleci

omry
Fix unsafe_merge crash with Union types (Issue #1087)

## Description
Fixes #1087
Supercedes #1088

This PR fixes an `AssertionError` crash that occurs when `OmegaConf.unsafe_merge` is used to merge configurations containing union types.

### Root Cause Analysis
During `unsafe_merge`, OmegaConf skips deepcopying of nodes (`no_deepcopy_set_nodes = True`). However, to prevent circular references, it still performs a safety check during `_set_item_impl` to see if the node being inserted belongs to the *same root config*:
```python
if self._get_root() is value._get_root():
    do_deepcopy = True
```

When a structured config is expanded and it contains a Union type, OmegaConf synthesizes a detached `UnionNode(MISSING)` and attempts to set it. Because `UnionNode` inherits from `Box`, `isinstance(value, Box)` is `True`, and the code executes `value._get_root()`.

Inside `Node._get_root()`, if a node has no parent, it asserts that it must be a `Container`:
```python
def _get_root(self) -> "Container":
    root: Optional[Box] = self._get_parent()
    if root is None:
        assert isinstance(self, Container)  # <--- CRASH
```
Because `UnionNode` is a `Box` but *not* a `Container`, the assertion fails and the program crashes. This bug is completely specific to `unsafe_merge` combined with `UnionNode`s, as other nodes are either not `Box`es (like `IntegerNode`) or are actually `Container`s (like `DictConfig`).

### The Fix
We safely bypass calling `value._get_root()` on detached nodes during the same-config check in `_set_item_impl`. By acknowledging that a detached node (where `_get_parent() is None`) is conceptually its own root, we use `value` directly in the identity check, completely avoiding the problematic assertion in `base.py`.

## Verification
- Added a parameterized test `test_merge_with_nested_structured_config_and_union_type` that ensures both `merge` and `unsafe_merge` evaluate correctly without crashing.
- Full test suite passes with 0 regressions.

2 of 2 new or added lines in 1 file covered. (100.0%)

3662 of 3662 relevant lines covered (100.0%)

1.0 hits per line

Relevant lines Covered
Build:
Build:
3662 RELEVANT LINES 3662 COVERED LINES
1.0 HITS PER LINE
Source Files on master
  • Tree
  • List 19
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
07bca34b... main Fix unsafe_merge crash with Union types (Issue #1087) ## Description Fixes #1087 Supercedes #1088 This PR fixes an `AssertionError` crash that occurs when `OmegaConf.unsafe_merge` is used to merge configurations containing union types. ### Root... push 01 May 2026 08:46PM UTC omry circleci
100.0
85a87a38... main Fix OmegaConf.resolve discrepancy on interpolation to missing OmegaConf.resolve() previously caught InterpolationToMissingValueError and silently overwrote the node with MISSING. This caused is_missing(cfg, "a") to flip False -> True across resol... push 01 May 2026 08:46PM UTC omry circleci
100.0
cd8a2be0... main README: point Backlog link to live Pages site push 30 Apr 2026 05:41AM UTC omry circleci
100.0
2979e2a6... main backlog-tool: extract from skill into standalone-installable subproject Move .claude/skills/update-backlog/ to subprojects/backlog-tool/, restructured as a pip-installable Python package with a 'backlog-tool' console script. CLI subcommands: * u... push 30 Apr 2026 05:10AM UTC omry circleci
100.0
ed95a1b4... sapling-pr-archive-omry Merge 9f7fc5001 into sapling-pr-archive-omry push 29 Apr 2026 08:41PM UTC web-flow circleci
100.0
97e08fa5... pr1289 Fix OmegaConf.resolve discrepancy on interpolation to missing OmegaConf.resolve() previously caught InterpolationToMissingValueError and silently overwrote the node with MISSING. This caused is_missing(cfg, "a") to flip False -> True across resol... Pull #1289 29 Apr 2026 08:41PM UTC omry circleci
100.0
0adfbf34... main Update documentation version in README Updated documentation badge version from 2.1_branch to 2.3_branch. push 29 Apr 2026 06:42PM UTC web-flow circleci
100.0
5dffcbbf... main Fix backlog workflow push retries push 29 Apr 2026 05:27AM UTC omry circleci
100.0
71f692d2... main updated organization of type adapter design docs push 29 Apr 2026 05:09AM UTC omry circleci
100.0
bc48b623... main Refactor type adapter design docs push 29 Apr 2026 05:01AM UTC omry circleci
100.0
See All Builds (2632)
  • Repo on GitHub
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc