PowerShell: preserve structured ARM failure details in `ErrorRecord`
维护者通常 1 天内回复
@VeryEarly 已经在做这个了。
开始于 2026年10月22日。
评估
这个 Issue 还没有评估数据。
描述
Summary
In the Az 0.1.4 preview bundle, Get-AzResourceGroup reports an ARM 404 through a generic System.Exception, with category NotSpecified and no populated ErrorDetails or TargetObject.
The HTTP status and ARM error code survive in the message text, but callers must parse that text to distinguish service failures reliably.
Reproduction
Using an authenticated profile and a resource-group name that does not exist:
try {
Get-AzResourceGroup `
-SubscriptionId '<subscription-id>' `
-Name 'azclips-ro-check-does-not-exist' `
-ErrorAction Stop
} catch {
[pscustomobject]@{
ExceptionType = $_.Exception.GetType().FullName
ErrorId = $_.FullyQualifiedErrorId
Category = $_.CategoryInfo.Category
ErrorDetails = $_.ErrorDetails
TargetObject = $_.TargetObject
Message = $_.Exception.Message
} | Format-List
}
Observed result
| Field | Observed value |
|---|---|
| Exception type | System.Exception |
| Error ID | ResourceGroupError,Microsoft.Azure.Azclips.Cmdlets.Resources.GetResourceGroupCmdlet |
| Category | NotSpecified |
| ErrorDetails | Null |
| TargetObject | Null |
| Message | HTTP 404, request URL, and embedded ARM JSON containing ResourceGroupNotFound |
-ErrorAction Stop and catch work. The concern is the information available inside the caught record, not whether the error is catchable.
As a control, an unknown cmdlet parameter retains a native ParameterBindingException, category InvalidArgument, and the specific NamedParameterNotFound error ID.
Relevant implementation
The released CmdletOutputStreamsFactory constructs an ErrorRecord using:
new Exception(value?.ToString() ?? string.Empty)
and a null target. This matches the observed generic exception and missing target.
Suggested improvement
Preserve the service failure information in a documented, programmatically accessible form:
- HTTP status and ARM error code.
- A meaningful error category—for example,
ObjectNotFoundfor this case. - The requested resource as
TargetObject. - An underlying exception or structured payload that retains useful service details.
Keep the human-readable message and existing -ErrorAction behavior. The goal is to let scripts handle a missing resource without matching strings inside a message.
Environment and scope
- Release:
v0.1.4.20260930T053744Z - Az rollup 0.1.4; Az.Resources 0.1.2
- PowerShell 7.6.4 on Debian 13
- Read-only request; no resources created or modified
- One ARM 404 case tested; other service-error categories were not tested
- 主要语言
- C#
- 星标
- 18
- 派生
- 10
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 157
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/azclips 的其他 Issue
-
act-identity-squad bug
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
act-identity-squad bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
act-identity-squad bug
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
act-identity-squad bug
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
act-experience-enablement-squad bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
Realm667/WolfenDoom#1758 ·
-
难度 1/5 1 小时以内 新手友好度 82/100
-
AI documentation good first issue help wanted
难度 1/5 1-3 小时 新手友好度 84/100
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
akshit-bansal11/edgepad#106 ·
维护者通常 1 天内回复