Skip to content

Error when parsing repository that uses multiselect custom-properties #3229

Description

@spalberg

Problem overview

We started using githubs custom properties recently and noticed that our reviewdog/action-actionlint checks started to fail with the following error:

reviewdog: failed to build repo base HTML URL: json: cannot unmarshal array into Go struct field Repository.custom_properties of type string

reviewdog/action-actionlint uses reviewdog/reviewdog which in turn uses the current version of google/go-github to parse github related json.

Analysis

Handling for custom_properties was added in this PR: #3065.
The field is expected to be a map of string values (https://github.com/google/go-github/pull/3065/files#diff-7a0544e44d81e972917728b13efd3fa55e7f9d1bd8edb745216494fa1e178f93R80).

The actual api response can also include non-string values. The following is part of an actual api response obtained by using the github cli (gh api repos/OWNER/REPO):

{
  // ...
  "allow_update_branch": true,
  "use_squash_pr_title_as_default": false,
  "squash_merge_commit_message": "COMMIT_MESSAGES",
  "squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
  "merge_commit_message": "PR_TITLE",
  "merge_commit_title": "MERGE_MESSAGE",
  "custom_properties": {
    "org-managed-rulesets": "true",
    "technologies": [
      "helm",
      "java"
    ]
  },
  // ...
}

The custom property technologies is multi select and github seems to return the selected values as an array which causes the parser to error out. The custom property org-managed-rulesets is of type boolean and represented using a string by github.

Sadly, githubs api docs are really bad when it comes to custom_property, so I can't say for sure if there are other output options than string or array of strings:

{
  // ...
  "custom_properties": {
      "type": "object",
      "description": "The custom properties that were defined for the repository. The keys are the custom property names, and the values are the corresponding custom property values.",
      "additionalProperties": true
  }
  // ...
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions