Skip to content

MetaService.Get fails because the schema of the JSON in the API response is different from the expected in APIMeta.Domains type #3248

@polamjag

Description

@polamjag

Downstream issue: integrations/terraform-provider-github#2357

GitHub has a meta information API, and go-github has a corresponding implementation:

In the response of this API endpoint, the JSON unmarshal always seems to fail for the Domains field -- because the type of the value is different from what is expected.

In go-github, values under domains property is expected to be map[string][]string:

go-github/github/meta.go

Lines 73 to 75 in 882755a

// A map of GitHub services and their associated domains. Note that many
// of these domains are represented as wildcards (e.g. "*.github.com").
Domains map[string][]string `json:"domains,omitempty"`

But it actually looks like this (see https://api.github.com/meta):

{
  ... snip ...,
  "domains": {
    "website": [ "*.github.com", ... snip ... ],
    "codespaces": [ "*.github.com", ... snip ... ],
    "copilot": [ "*.github.com", ... snip ... ],
    "packages": [ "mavenregistryv2prod.blob.core.windows.net", ... snip ... ],
    "actions": [ "*.actions.githubusercontent.com", ... snip ... ],
    "artifact_attestations": {
      "trust_domain": "",
      "services": [ "*.actions.githubusercontent.com", ... snip ... ]
    }
  }
}

The values under artifact_attestations field clearly deviates from the []string type.

This incompatibility causes MetaService.Get() to fail with errors like Error: json: cannot unmarshal object into Go struct field APIMeta.domains of type []string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking API ChangePR will require a bump to the major version num in next release. Look here to see the change(s).buggood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions