Skip to content

Collections: ignore_case=KEYS does not normalize nested dictionary keys #5858

Closed

Description

@anticipate218

With Robot Framework 7.5.2.dev1 at master commit 8e6a235 (Python 3.13.5, Windows 11 10.0.26200), Collections does not apply ignore_case=KEYS to dictionaries nested inside a dictionary value. The same problem occurs when the nested dictionary is inside a list.

Reproduction

from robot.libraries.Collections import Collections

collections = Collections()
collections.dictionaries_should_be_equal(
    {"A": {"B": "Value"}},
    {"a": {"b": "Value"}},
    ignore_case="KEYS",
)

Expected: the dictionaries compare equal because only key capitalization differs, including the nested key. Recursive key/value handling is documented and was explicitly discussed in #4343 (#4343 (comment)).

Observed:

Following keys have different values:
Key a: {'B': 'Value'} != {'b': 'Value'}

Using {"A": [{"B": "Value"}]} and {"a": [{"b": "Value"}]} fails in the same way. Both cases also fail through the real Robot acceptance-test runner. As a diagnostic clue, adding an unrelated ignore_keys=["unused"] makes the first example pass on the same unchanged source.

Investigation

normalize_value() temporarily sets self.ignore_case to false in KEYS mode. Then normalize() returns early because Normalizer.__bool__() uses that temporary flag, so it never reaches the nested dictionary.

A fix needs to preserve the existing container semantics as well as enabling recursion. Simply forcing traversal can expose the sequence reconstruction fallback: namedtuple values or range(2) must not become equal to a plain list, and VALUES mode must preserve hashable namedtuple keys. I have not submitted the experimental patch because it changes those comparisons. The original defect and these counterexamples are reproducible; the intended behavior remains recursive key normalization while keeping values case-sensitive.

AI assistance was used for investigation and local verification.

Activity

  1. added this to the v7.6 milestone on Nov 18, 2026
  2. added
    acknowledge
    on Nov 18, 2026
  3. added theissue type on Nov 18, 2026
  4. pekkaklarck commented on Nov 18, 2026

    @pekkaklarck
    Member

    Thanks for the report @anticipate218. The problem that the KEYS mode is not recursive is easy to fix and PR #5859 by @wangqiao258 does that nicely.

    Can you clarify your concerns about container types changing? We try to preserve types (see the _try_to_preserve_type method), but that won't work in all cases. If you have ideas how to enhance the situation, we certainly can do something to it. That should get its own issue, though.

    PR #5859 looks so good that I'll merge it now anyway. I assigned this issue to RF 7.6, but if we still release RF 7.5.2 this will be already part of it.

  5. anticipate218 commented on Nov 18, 2026

    @anticipate218
    Author

    Thanks for fixing the recursive KEYS case. I verified that it now works at 429888e.

    I filed the requested separate container-normalization report at #5861. It includes before/after examples where VALUES turns namedtuple/range keys into unhashable lists, and KEYS makes those values compare equal to plain lists. I reproduced both changes with the Collections API and the Robot runner.

    AI assistance was used for the investigation and this reply.

  6. added a commit that references this issue on Nov 18, 2026
    429888e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgeeffort: smallpriority: medium

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions