Skip to content

Comments

Fix compose crash when overriding Optional structured field set to None#3126

Open
ItsMacto wants to merge 1 commit intofacebookresearch:mainfrom
ItsMacto:fix/issue-2502-merge-crash
Open

Fix compose crash when overriding Optional structured field set to None#3126
ItsMacto wants to merge 1 commit intofacebookresearch:mainfrom
ItsMacto:fix/issue-2502-merge-crash

Conversation

@ItsMacto
Copy link

@ItsMacto ItsMacto commented Feb 5, 2026

Motivation

Composing an override that merges a dictionary into an Optional structured config field defaulting to None (e.g. Optional[Child] = None overridden with {"child": {}}) can raise an AssertionError or ValidationError during config composition, depending on the OmegaConf version.

This PR fixes the issue by defensively materializing None-valued optional structured nodes prior to merge, using the node’s structured reference type when available. A regression test is added to ensure composing such overrides no longer crashes and produces a correctly typed structured node.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

  • Added a regression test in tests/test_compose.py that reproduces the failure case and asserts correct behavior.
  • Verified locally:
    • pytest tests/test_compose.py
    • pytest tests/test_hydra.py

No special setup is required beyond the standard test environment.

Related Issues and PRs

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] compose AssertionError on key pointing into None-valued DictConfig.

1 participant