dotnet/runtime · error · ValueError

Invalid summary_type

Error message

Invalid summary_type: {coreclr_args.summary_type}

What it means

Raised as a ValueError (not RuntimeError) by summarize_json_summaries when coreclr_args.summary_type is not one of the three supported keys: 'asmdiffs', 'metricdiff', or 'tpdiff'. The summary_type selects which JSON summary format to aggregate and which output filename prefix to use, so an unknown value cannot be mapped. The valid set is logged just before the raise.

Solutions

  1. Pass one of the documented values: --summary_type asmdiffs | metricdiff | tpdiff.
  2. Check the error log line immediately preceding the exception, which prints the accepted values.
  3. If adding a new summary kind, extend the summary_type_to_prefix dict in summarize_json_summaries.

Example fix

// before
summary_type_to_prefix = {"asmdiffs": "diff", "metricdiff": "metricdiff", "tpdiff": "tpdiff"}
if coreclr_args.summary_type not in summary_type_to_prefix:
    raise ValueError(f"Invalid summary_type: {coreclr_args.summary_type}")
// after (fix invocation)
python superpmi.py summary --summary_type asmdiffs --summaries file1.json file2.json
Defensive patterns

Strategy: validation

Validate before calling

VALID_SUMMARY_TYPES = {'asmdiffs', 'metricdiff', 'tpdiff'}
def validate_summary_type(summary_type):
    if summary_type not in VALID_SUMMARY_TYPES:
        raise ValueError(f"Invalid summary_type '{summary_type}'. Valid values: {sorted(VALID_SUMMARY_TYPES)}")
    return summary_type

Type guard

from typing import Literal
SummaryType = Literal['asmdiffs', 'metricdiff', 'tpdiff']
def is_valid_summary_type(value: str) -> bool:
    return value in {'asmdiffs', 'metricdiff', 'tpdiff'}

Prevention

When it happens

Trigger: Called in the 'summary' subcommand path: after logging the invalid value and the list of valid values, if coreclr_args.summary_type not in {'asmdiffs','metricdiff','tpdiff'} the ValueError is raised. Occurs when --summary_type is omitted but defaults to something invalid, mistyped (e.g. 'asm-diffs', 'asmdiff'), or a new summary kind that hasn't been registered in summary_type_to_prefix.

Common situations: Typo in --summary_type (e.g. 'asmdiff' instead of 'asmdiffs', 'tp' instead of 'tpdiff'); invoking summarize with a summary_type from a newer/older tool version; a CI script passing the wrong token.

Related errors


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

Appendix: source

Thrown at src/coreclr/scripts/superpmi.py:4697

def summarize_json_summaries(coreclr_args):
    logging.info("Summarizing {} files:".format(coreclr_args.summary_type))
    for file in coreclr_args.summaries:
        logging.info("  {}".format(file))

    summary_type_to_prefix = {
        "asmdiffs": "diff",
        "metricdiff": "metricdiff",
        "tpdiff": "tpdiff",
    }

    if coreclr_args.summary_type not in summary_type_to_prefix:
        logging.error(
            "Invalid summary_type '%s'. Valid values are: %s",
            coreclr_args.summary_type,
            ", ".join(sorted(summary_type_to_prefix.keys())),
        )
        raise ValueError(f"Invalid summary_type: {coreclr_args.summary_type}")

    file_name_prefix = summary_type_to_prefix[coreclr_args.summary_type]
    if coreclr_args.output_long_summary_path:
        overall_md_summary_file = coreclr_args.output_long_summary_path
    else:
        overall_md_summary_file = create_unique_file_name(coreclr_args.spmi_location, file_name_prefix + "_summary", "md")
        if os.path.isfile(overall_md_summary_file):
            os.remove(overall_md_summary_file)

    short_md_summary_file = create_unique_file_name(coreclr_args.spmi_location, file_name_prefix + "_short_summary", "md")
    if os.path.isfile(short_md_summary_file):
        os.remove(short_md_summary_file)

    if coreclr_args.summary_type == "asmdiffs":
        base_jit_options = []
        diff_jit_options = []
        summarizable_asm_diffs = []

View on GitHub (pinned to 60108ba66e)