Skip to content

fix: V1ConfigurationMapper - return empty list for null Dimensions to prevent ArgumentNullException#2743

Merged
tomkerkhove merged 1 commit into
tomkerkhove:masterfrom
Krishna-Chaitanya4:fix/v1-mapper-dimensions-null-fix
Mar 28, 2026
Merged

fix: V1ConfigurationMapper - return empty list for null Dimensions to prevent ArgumentNullException#2743
tomkerkhove merged 1 commit into
tomkerkhove:masterfrom
Krishna-Chaitanya4:fix/v1-mapper-dimensions-null-fix

Conversation

@Krishna-Chaitanya4
Copy link
Copy Markdown
Contributor

@Krishna-Chaitanya4 Krishna-Chaitanya4 commented Mar 27, 2026

Summary

Fixes a regression introduced in PR #2740 where the V1ConfigurationMapper returns null for AzureMetricConfiguration.Dimensions when the source has no dimensions configured. The AzureMetricConfigurationValidator calls .Any() on this property, which throws ArgumentNullException when it is null.

Root Cause

AutoMapper defaulted null collections to empty lists. The hand-written mapper preserved null, but downstream validators expect non-null collections.

Error

System.ArgumentNullException: Value cannot be null. (Parameter 'source') at System.Linq.Enumerable.Any[TSource](IEnumerable source) at AzureMetricConfigurationValidator.ValidateAzureMetricConfiguration(line 58)

Fix

`diff

  • Dimensions = source.Dimensions?.Select(MapMetricDimension).ToList(),
  • Dimensions = source.Dimensions?.Select(MapMetricDimension).ToList() ?? new List(),
    `

Verification

  • Build: 0 errors, 0 warnings
  • Unit tests: 1542 passed, 0 failed

@github-actions
Copy link
Copy Markdown

Thank you for your contribution! 🙏 We will review it as soon as possible.

@Krishna-Chaitanya4
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 2743 in repo tomkerkhove/promitor

@Krishna-Chaitanya4 Krishna-Chaitanya4 force-pushed the fix/v1-mapper-dimensions-null-fix branch from faf901b to a1501e6 Compare March 28, 2026 03:36
@tomkerkhove tomkerkhove merged commit 78cbe21 into tomkerkhove:master Mar 28, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants