Summary
plugins/deploy-on-aws/scripts/lib/fix_step_badges.py calls defusedxml.ElementTree.indent(...) but defusedxml.ElementTree does not export an indent() function on older releases. The stdlib xml.etree.ElementTree.indent() was added in Python 3.9, and defusedxml did not mirror it until a relatively recent release. On systems with an older defusedxml (still commonly installed via system Python, distro packages, or pinned envs), the badge post-processor crashes with:
AttributeError: module 'defusedxml.ElementTree' has no attribute 'indent'
The offending line is fix_step_badges.py:486:
import defusedxml.ElementTree as ET
...
ET.indent(tree, space=" ")
Steps to reproduce
- Install the
deploy-on-aws plugin from awslabs/agent-plugins.
- In an environment with an older
defusedxml (one that doesn't re-export indent), generate any architecture diagram that triggers the post-processing pipeline.
- The badge-overlap fixer step crashes with the
AttributeError above.
Workaround
Monkey-patch defusedxml.ElementTree.indent = xml.etree.ElementTree.indent before invoking the script.
Suggested fix
indent() is a pure write-side, pretty-print operation — there is no XML-parsing security risk in falling back to the stdlib implementation. Keep defusedxml for parsing, use stdlib indent for output:
import xml.etree.ElementTree as _ET
import defusedxml.ElementTree as ET
...
# defusedxml lacks indent() on older versions; stdlib indent is safe here
# because it's a write-only pretty-print, not parsing.
try:
ET.indent(tree, space=" ")
except AttributeError:
_ET.indent(tree, space=" ")
Alternatively, just bump the minimum defusedxml version in the plugin's requirements to one that ships indent().
Happy to send a small PR with the one-line patch if useful.
Summary
plugins/deploy-on-aws/scripts/lib/fix_step_badges.pycallsdefusedxml.ElementTree.indent(...)butdefusedxml.ElementTreedoes not export anindent()function on older releases. The stdlibxml.etree.ElementTree.indent()was added in Python 3.9, anddefusedxmldid not mirror it until a relatively recent release. On systems with an olderdefusedxml(still commonly installed via system Python, distro packages, or pinned envs), the badge post-processor crashes with:The offending line is
fix_step_badges.py:486:Steps to reproduce
deploy-on-awsplugin fromawslabs/agent-plugins.defusedxml(one that doesn't re-exportindent), generate any architecture diagram that triggers the post-processing pipeline.AttributeErrorabove.Workaround
Monkey-patch
defusedxml.ElementTree.indent = xml.etree.ElementTree.indentbefore invoking the script.Suggested fix
indent()is a pure write-side, pretty-print operation — there is no XML-parsing security risk in falling back to the stdlib implementation. Keepdefusedxmlfor parsing, use stdlibindentfor output:Alternatively, just bump the minimum
defusedxmlversion in the plugin's requirements to one that shipsindent().Happy to send a small PR with the one-line patch if useful.