Skip to content

ErrorDetail.UnmarshalJSON aborts entire Machines list response when errorDetails contains a string element #26945

Description

@AmitOttenheimer
  • Import path of package in question: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridcompute/armhybridcompute

    • SDK version: v1.2.0 — also reproduces in v2.0.0 (latest stable) and v2.1.0-beta.3 (the ErrorDetail.UnmarshalJSON body is byte-for-byte identical across all three).
    • Go version: go version go1.22 darwin/arm64 (also reproduces on linux/amd64)

    armhybridcompute.MachinesClient.NewListBySubscriptionPager(...).NextPage(ctx) fails with an unmarshal error and returns zero machines whenever Azure returns any element of properties.errorDetails as a plain JSON string
    instead of an ErrorDetail object. One bad element in one machine aborts the entire page, so callers lose every machine in the response — not just the offending one.

    We are seeing this in production on two subscriptions in a customer tenant. Azure returns response bodies of the shape:

    {
      "value": [
        {
          "id": "/subscriptions/.../providers/Microsoft.HybridCompute/machines/<name>",
          "properties": {
            "status": "Disconnected",
            "errorDetails": ["machine offline"]      // <-- string, not object
          }
        }
      ]
    }

    The pager should either:

    1. Tolerate the string shape (e.g. by treating it as ErrorDetail{Message: &s}), or
    2. Skip the malformed element and still return the rest of the page,

    so that a single malformed errorDetails element does not nullify the entire list response.

    pager.NextPage(ctx) returns:

    unmarshalling type *armhybridcompute.MachineListResult:
      struct field Value:
        unmarshalling type *armhybridcompute.Machine:
          struct field Properties:
            unmarshalling type *armhybridcompute.MachineProperties:
              struct field ErrorDetails:
                unmarshalling type *armhybridcompute.ErrorDetail:
                  json: cannot unmarshal string into Go value of type map[string]json.RawMessage
    

    ErrorDetail.UnmarshalJSON in sdk/resourcemanager/hybridcompute/armhybridcompute/models_serde.go (lines 212–242 in v1.2.0) hard-requires a JSON object on the very first call:

Metadata

Metadata

Assignees

Labels

MgmtThis issue is related to a management-plane library.Service AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions