salt.utils.xmlutil relies on deprecated Element truth-value testing
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in salt/utils/xmlutil.py and inspect the truth-value checks in to_dict() and clean_node(), including the patterns shown in the issue. Run the provided warnings-as-errors reproduction with Python 3.14; done means the conversion completes without a DeprecationWarning while preserving the XML-to-dictionary behavior.
Written by the indexing model from the issue text.
Description
Description of Issue
salt/utils/xmlutil.py tests the truth value of xml.etree.ElementTree.Element objects directly (e.g. if not xmltree:, if item:, if ... and parent:), which triggers:
DeprecationWarning: Testing an element's truth value will always return True in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
This is emitted on every call to salt.utils.xmlutil.to_dict()/clean_node(), which is used by salt.utils.aws.query() for essentially every AWS API request/response (and therefore by every call made through the ec2 cloud driver, virt XML handling, etc).
This is the same underlying issue as #56475 (getchildren() deprecation in the same file), which was fixed for iteration but not for truth-value testing.
Steps to Reproduce Issue
import warnings
import xml.etree.ElementTree as ET
import salt.utils.xmlutil as xml
with warnings.catch_warnings():
warnings.simplefilter("error")
xml.to_dict(ET.fromstring("<parent>data</parent>"))
DeprecationWarning: Testing an element's truth value will always return True in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
Or simply run salt-cloud -p <profile> <name> against an ec2 provider and watch the logs.
Versions Report
Reproduced against current master with Python 3.14.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from saltstack/salt
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug needs-triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
# [BUG] deltaproxy: sub-proxy init failures are logged at INFO and invisible at default log level Openbug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100