Skip to content

az consumption usage list -m : meterDetails.totalIncludedQuantity is overwritten with pretaxStandardRate #33907

Description

@8dazo

Describe the bug

az consumption usage list --include-meter-details (-m) and az consumption pricesheet show --include-meter-details stringify meterDetails incorrectly.

totalIncludedQuantity (included quantity on the offer) is copied from pretaxStandardRate (pretax listing price). The two fields then always match, so the service value for included quantity is lost.

This is not an alias. Before the AAZ migration in #27152, the transformer converted each field on its own:

result.meter_details.total_included_quantity = str(result.meter_details.total_included_quantity)
result.meter_details.pretax_standard_rate = str(result.meter_details.pretax_standard_rate)

After the migration, both lines read pretaxStandardRate:

result['meterDetails']['totalIncludedQuantity'] = str(result['meterDetails'].get('pretaxStandardRate', None))
result['meterDetails']['pretaxStandardRate'] = str(result['meterDetails'].get('pretaxStandardRate', None))

The same pair is in pricesheet_show_properties. The MeterDetails contract treats them as different properties (quantity vs price). AAZ still models both floats separately.

Related command

az consumption usage list -m
az consumption usage list -a -m
az consumption pricesheet show --include-meter-details

Errors

No exception. Output is wrong.

If the service returns:

"meterDetails": {
  "totalIncludedQuantity": 100,
  "pretaxStandardRate": 0.05
}

CLI prints:

"meterDetails": {
  "totalIncludedQuantity": "0.05",
  "pretaxStandardRate": "0.05"
}

If pretaxStandardRate is missing, both become "None" even when totalIncludedQuantity was present.

Issue script & Debug output

Repro from current dev (src/azure-cli/azure/cli/command_modules/consumption/custom.py):

item = {
    "usageStart": "2018-02-01T00:00:00Z",
    "usageEnd": "2018-02-01T23:59:59Z",
    "usageQuantity": 1,
    "billableQuantity": 1,
    "pretaxCost": 5,
    "meterDetails": {
        "meterName": "Compute Hours",
        "totalIncludedQuantity": 100,
        "pretaxStandardRate": 0.05,
    },
}
# after transform_usage_output(item):
# meterDetails.totalIncludedQuantity == "0.05"   # wrong, should be "100"
# meterDetails.pretaxStandardRate == "0.05"      # ok

--debug still shows the REST body with the original totalIncludedQuantity. The overwrite happens in CLI output transform after the HTTP response.

Expected behavior

Each field is stringified from its own service value, same as pre-AAZ:

"meterDetails": {
  "totalIncludedQuantity": "100",
  "pretaxStandardRate": "0.05"
}

Environment Summary

azure-cli                         2.89.1
core                              2.89.1

Reproduced on current dev at src/azure-cli/azure/cli/command_modules/consumption/custom.py (usage transform ~L106–107, pricesheet transform ~L249–250).

Additional context

Existing scenario tests do not catch this: _validate_usage(..., includeMeterDetails=True) only checks meterDetails['meterName']. Recordings often omit totalIncludedQuantity / pretaxStandardRate.

No existing GitHub issue describes this. Nearby tickets #28323 and #30749 are the usageStart KeyError, a different bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Service AttentionThis issue is responsible by Azure service team.consumptioncustomer-reportedIssues that are reported by GitHub users external to the Azure organization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions