dotnet/runtime · error · ValueError

unknown attribute: {} in template:{}

Error message

unknown attribute: {} in template:{}

What it means

Raised by parseTemplateNodes() in genEventing.py when a <data> element inside a <template> in the ETW manifest has an XML attribute that is not in the set of recognized attributes. Recognized attributes are: name, inType, count, length (used), and map, outType (ignored). Any other attribute triggers a ValueError.

Source

Thrown at src/coreclr/scripts/genEventing.py:353

    #return values
    allTemplates           = {}

    for templateNode in templateNodes:
        structCounts = {}
        arrays = {}
        templateName    = templateNode.getAttribute('tid')
        var_Dependencies = {}
        fnPrototypes    = FunctionSignature()
        dataNodes       = getTopLevelElementsByTagName(templateNode,'data')

        # Validate that no new attributes has been added to manifest
        for dataNode in dataNodes:
            nodeMap = dataNode.attributes
            for attrib in nodeMap.values():
                attrib_name = attrib.name
                if attrib_name not in ignoredXmlTemplateAttribes and attrib_name not in usedXmlTemplateAttribes:
                    raise ValueError('unknown attribute: '+ attrib_name + ' in template:'+ templateName)

        for dataNode in dataNodes:
            variable = dataNode.getAttribute('name')
            wintype = dataNode.getAttribute('inType')

            #count and length are the same
            wincount  = dataNode.getAttribute('count')
            winlength = dataNode.getAttribute('length');

            var_Props = None
            var_dependency = [variable]
            if  winlength:
                if wincount:
                    raise Exception("both count and length property found on: " + variable + "in template: " + templateName)
                wincount = winlength

            if (wincount.isdigit() and int(wincount) ==1):
                wincount = ''

View on GitHub (pinned to 60108ba66e)

Solutions

  1. Identify the unexpected attribute from the error message (it includes the attribute name and template tid).
  2. If the attribute is intentional, add it to ignoredXmlTemplateAttribes or usedXmlTemplateAttribes in genEventing.py and handle it in the parsing logic.
  3. If the attribute is accidental, remove it from the <data> element in the manifest.
  4. Ensure the manifest complies with the ETW manifest schema expected by the code generator.

Example fix

# before
ignoredXmlTemplateAttribes = frozenset(["map","outType"])
usedXmlTemplateAttribes    = frozenset(["name","inType","count", "length"])

# after - add the new attribute to the ignored set if it's metadata-only
ignoredXmlTemplateAttribes = frozenset(["map","outType","length2"])
usedXmlTemplateAttribes    = frozenset(["name","inType","count", "length"])
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED_DATA_ATTRS = frozenset(["name", "inType", "count", "length", "map", "outType"])

def validate_template_attributes(manifest_path: str) -> list:
    """Return list of unknown attributes found in template data elements."""
    import xml.dom.minidom as DOM
    tree = DOM.parse(manifest_path)
    issues = []
    for template in tree.getElementsByTagName('template'):
        tid = template.getAttribute('tid')
        for data in template.getElementsByTagName('data'):
            for attr in data.attributes.values():
                if attr.name not in ALLOWED_DATA_ATTRS:
                    issues.append(f"Unknown attr '{attr.name}' on data '{data.getAttribute('name')}' in template '{tid}'")
    return issues

Type guard

null

Try / catch

try:
    allTemplates = parseTemplateNodes(templateNodes)
except ValueError as e:
    if 'unknown attribute' in str(e):
        print(f"Manifest schema error: {e}")
        print("Either remove the attribute or add it to ignoredXmlTemplateAttribes/usedXmlTemplateAttribes.")
    raise

Prevention

When it happens

Trigger: Triggered when iterating over dataNode.attributes for each <data> element in a template, and an attribute name is found that is not in ignoredXmlTemplateAttribes (frozenset ['map','outType']) nor usedXmlTemplateAttribes (frozenset ['name','inType','count','length']). This is a schema validation guard to catch manifest changes that introduce attributes the code generator doesn't understand.

Common situations: A developer adds a new attribute to a <data> element in ClrEtwAll.man (e.g., 'length2', 'scale', 'display', etc.) that the code generator hasn't been taught about. A manifest editing tool auto-inserts unexpected attributes. The manifest schema was extended but genEventing.py wasn't updated to handle or explicitly ignore the new attribute.

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/126cbc8566995a0b. Report an issue: GitHub.