{"record":{"id":"7969ea365daad91b","repo":"dotnet/runtime","slug":"unknown-level-level","errorCode":null,"errorMessage":"unknown level {level}","messagePattern":"unknown level (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/genEventing.py","lineNumber":748,"sourceCode":"            allTemplates  = parseTemplateNodes(templateNodes)\n            eventNodes = providerNode.getElementsByTagName('event')\n            #pal: create etmdummy.h\n            Clretwdummy.write(generateclrEtwDummy(eventNodes, allTemplates) + \"\\n\")\n\ndef convertToLevelId(level):\n    if level == \"win:LogAlways\":\n       return 0\n    if level == \"win:Critical\":\n       return 1\n    if level == \"win:Error\":\n       return 2\n    if level == \"win:Warning\":\n       return 3\n    if level == \"win:Informational\":\n       return 4\n    if level == \"win:Verbose\":\n       return 5\n    raise Exception(\"unknown level \" + level)\n\ndef getKeywordsMaskCombined(keywords, keywordsToMask):\n    mask = 0\n    for keyword in keywords.split(\" \"):\n       if keyword == \"\":\n          continue\n       mask |= keywordsToMask[keyword]\n\n    return mask\n\ndef updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, is_host_windows, eventpipe_trace_context_typedef, dotnet_trace_context_typedef_windows, tree, clrallevents, inclusion_list, generatedFileType):\n    with open_for_update(clrallevents) as Clrallevents:\n        Clrallevents.write(stdprolog)\n        Clrallevents.write('#include <minipal/guid.h>\\n\\n')\n        if generatedFileType==\"header-impl\":\n            if runtimeFlavor.mono:\n                Clrallevents.write(getCoreCLRMonoNativeAotTypeAdaptionDefines() + \"\\n\")\n            if runtimeFlavor.coreclr or write_xplatheader:","sourceCodeStart":730,"sourceCodeEnd":766,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/scripts/genEventing.py#L730-L766","documentation":"Raised by convertToLevelId() in genEventing.py when an event's 'level' attribute doesn't match any of the six recognized ETW severity levels. The recognized levels are: win:LogAlways (0), win:Critical (1), win:Error (2), win:Warning (3), win:Informational (4), win:Verbose (5). Any other level string causes the exception.","triggerScenarios":"Triggered when convertToLevelId(levelName) is called (from the clrproviders.h generation loop at line 943 where levelName = eventNode.getAttribute('level')) and the value doesn't match any of the if-conditions. This happens for typos, non-standard level names, or custom levels defined via <level> elements in the manifest that aren't in the standard set.","commonSituations":"A developer types 'win:Info' instead of 'win:Informational', or 'win:Fatal' instead of 'win:Critical'. A manifest uses a custom level name defined in a <level> element that the code generator doesn't map. An XML namespace prefix is missing or different (e.g., 'Informational' without the 'win:' prefix).","solutions":["Check the 'level' attribute on the event element identified in the manifest.","Use one of the exact strings: win:LogAlways, win:Critical, win:Error, win:Warning, win:Informational, win:Verbose.","If a custom level is needed, add a mapping for it in convertToLevelId().","Ensure the 'win:' prefix is present on standard level names."],"exampleFix":"<!-- before: incorrect level name -->\n<event symbol=\"MyEvent\" value=\"1\" level=\"win:Info\" template=\"t:MyEvent\" />\n\n<!-- after: correct level name -->\n<event symbol=\"MyEvent\" value=\"1\" level=\"win:Informational\" template=\"t:MyEvent\" />","handlingStrategy":"validation","validationCode":"VALID_LEVELS = frozenset([\n    'win:LogAlways', 'win:Critical', 'win:Error',\n    'win:Warning', 'win:Informational', 'win:Verbose'\n])\n\ndef validate_event_levels(manifest_path: str) -> list:\n    \"\"\"Return list of events with unrecognized level values.\"\"\"\n    import xml.dom.minidom as DOM\n    tree = DOM.parse(manifest_path)\n    issues = []\n    for event in tree.getElementsByTagName('event'):\n        level = event.getAttribute('level')\n        symbol = event.getAttribute('symbol')\n        if level not in VALID_LEVELS:\n            issues.append(f\"Event '{symbol}' has invalid level '{level}'. Valid: {sorted(VALID_LEVELS)}\")\n    return issues","typeGuard":"null","tryCatchPattern":"try:\n    level_id = convertToLevelId(levelName)\nexcept Exception as e:\n    if 'unknown level' in str(e):\n        print(f\"Invalid event level: {e}\")\n        print(f\"Use one of: {sorted(VALID_LEVELS)}\")\n    raise","preventionTips":["Always use the exact 'win:' prefixed level names from the standard ETW level set.","Double-check level spelling: 'win:Informational' not 'win:Info', 'win:Critical' not 'win:Fatal'.","Add a manifest validation step before code generation.","If custom levels are needed, extend convertToLevelId() with the new mapping."],"tags":["etw","manifest","eventing","coreclr","validation"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}