Azure / Azure/azure-powershell
Set-AzAlertProcessingRule non-descriptive error when passing inputobject using get-AzAlertProcessingRule
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
When passing an alert processing rule from get-azalertprocessingrule to set-azalertprocessingrule via inputobject, a non-descriptive error is returned referencing a parameter that does not exist (not output by get-azalertprocessingrule nor in the relevent documentation for these cmdlets).
Set-AzAlertProcessingRule: Value cannot be null. (Parameter 'value')
### Issue script & Debug output
```PowerShell
PS> $rules = Get-azalertprocessingrule
PS> $rules[0]
Name Enabled LastModifiedAt LastModifiedBy Type
---- ------- -------------- -------------- ----
rulename01 False 16/03/2025 11:41:46 PM 324120b1-b1bf-4542-8859-337e3ce74357 RemoveAllActionGroups
PS> $rules[0].Enabled = $true
PS> $debugpreference='continue'
PS> Set-AzAlertProcessingRule -InputObject $rule[0]
DEBUG: 10:31:45 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:31:45 AM - SetAzureAlertProcessingRule begin processing with ParameterSet 'ByInputObject'.
DEBUG: 10:31:45 AM - using account id 'user@local.host'...
DEBUG: 10:31:45 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.AlertsManagement], Cmdlet = [Set-AzAlertProcessingRule]. Returning default value [True].
DEBUG: 10:31:45 AM - [ConfigManager] Got nothing from [EnableErrorRecordsPersistence], Module = [Az.AlertsManagement], Cmdlet = [Set-AzAlertProcessingRule]. Returning default value [False].
Set-AzAlertProcessingRule: Value cannot be null. (Parameter 'value')
DEBUG: 10:31:45 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.AlertsManagement], Cmdlet = [Set-AzAlertProcessingRule]. Returning default value [True].
DEBUG: 10:31:45 AM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:31:45 AM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.AlertsManagement:0.6.3; CommandName: Set-AzAlertProcessingRule; PSVersion: 7.4.3; IsSuccess: False; Duration: 00:00:00.0094558; SanitizeDuration: 00:00:00; Exception: Value cannot be null. (Parameter 'value');
DEBUG: 10:31:45 AM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:31:46 AM - SetAzureAlertProcessingRule end processing.
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 4.0.2 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 0.6.3 Az.AlertsManagement {Get-AzAlert, Get-AzAlertObjectHistory, Get-AzAlertProcessingRule, Get-AzSmartGroup…}
```
### Error output
```PowerShell
Message : Value cannot be null. (Parameter 'value')
StackTrace : at Microsoft.Azure.Commands.AlertsManagement.SetAzureAlertProcessingRule.ProcessRecordInternal()
at Microsoft.Azure.Commands.AlertsManagement.AlertsManagementBaseCmdlet.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.ArgumentNullException
InvocationInfo : {Set-AzAlertProcessingRule}
Line : set-azalertprocessingrule -InputObject $rules[0]
Position : At line:1 char:1
+ set-azalertprocessingrule -InputObject $rules[0]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 3
```
Contributor guide
Research direction
Start at SetAzureAlertProcessingRule.ProcessRecordInternal(), the entry point named in the stack trace, and trace the ByInputObject path used by Set-AzAlertProcessingRule. Reproduce the command with Get-AzAlertProcessingRule output and verify that it no longer returns the non-descriptive null-parameter error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, powershell
- Domain
- backend, cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100