Skip to content

Broken logic in grains management with new default YAML loader #64017

Closed

Description

@tgriffitts-ns

salt/salt/utils/data.py

Lines 852 to 854 in eaeccf7

try:
ptr = ptr[each]
except KeyError:

This logic is no longer valid. The new YAML loader now constructs a dictionary object which supplies a default empty object data value when a not-present key is requested from the dictionary. This means that an exception is no longer thrown in the case of an absent key. The fix is simple. Don't rely on the exception to determine if a key exists within the dictionary. Simply check if the key exists. The problems this has caused are documented in tickets like the one below, which has a patch to fix the issue:

#47912 (comment)

Activity

  1. added
    bug
    Core
    on Apr 6, 2023
  2. added this to the Sulfur v3006.1 milestone on Apr 18, 2023
  3. added
    help-wanted
    on Jun 18, 2024
  4. modified the milestones: Sulfur v3006.9, Approved on Jun 18, 2024
  5. modified the milestones: Approved, Sulphur v3006.26 on Jul 2, 2026
  6. dwoz commented on Jul 2, 2026

    @dwoz
    Contributor

    Fix merged and shipped in a supported release. Closing per bulk triage. Reopen if this reproduces on a currently supported release (3006.x, 3007.x, 3008.x, master).

  7. added 2 commits that reference this issue on Jul 3, 2026
    fb500ba
    6b0e94a
  8. added a commit that references this issue on Jul 23, 2026
    b4987fd
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

    Corebughelp-wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions