Closed Bug 1821478 Opened 1 year ago Closed 1 year ago

[GITHUB] Fall back to author.name if author.username is missing

Categories

(bugzilla.mozilla.org :: API, defect)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: RyanVM, Assigned: dkl)

References

Details

(Keywords: requested-mobile)

Attachments

(1 file)

For the below PR, we received an error from BMO when the webhook ran:
https://github.com/mozilla-mobile/firefox-android/pull/1134

Payload:

{
  "ref": "refs/heads/main",
  "before": "da121523462a24bfecbc3236039477be76493a0d",
  "after": "550651142b3d0edb9567f99cdb94bf154f494bfa",
  "repository": {
    "id": 518992906,
    "node_id": "R_kgDOHu80Cg",
    "name": "firefox-android",
    "full_name": "mozilla-mobile/firefox-android",
    "private": false,
    "owner": {
      "name": "mozilla-mobile",
      "email": null,
      "login": "mozilla-mobile",
      "id": 22351667,
      "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyMzUxNjY3",
      "avatar_url": "https://avatars.githubusercontent.com/u/22351667?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/mozilla-mobile",
      "html_url": "https://github.com/mozilla-mobile",
      "followers_url": "https://api.github.com/users/mozilla-mobile/followers",
      "following_url": "https://api.github.com/users/mozilla-mobile/following{/other_user}",
      "gists_url": "https://api.github.com/users/mozilla-mobile/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/mozilla-mobile/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/mozilla-mobile/subscriptions",
      "organizations_url": "https://api.github.com/users/mozilla-mobile/orgs",
      "repos_url": "https://api.github.com/users/mozilla-mobile/repos",
      "events_url": "https://api.github.com/users/mozilla-mobile/events{/privacy}",
      "received_events_url": "https://api.github.com/users/mozilla-mobile/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "html_url": "https://github.com/mozilla-mobile/firefox-android",
    "description": "This repository hosts the Firefox for Android (Fenix), Focus for Android, and Mozilla Android Components projects.",
    "fork": false,
    "url": "https://github.com/mozilla-mobile/firefox-android",
    "forks_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/forks",
    "keys_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/teams",
    "hooks_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/hooks",
    "issue_events_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/issues/events{/number}",
    "events_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/events",
    "assignees_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/assignees{/user}",
    "branches_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/branches{/branch}",
    "tags_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/tags",
    "blobs_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/languages",
    "stargazers_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/stargazers",
    "contributors_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/contributors",
    "subscribers_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/subscribers",
    "subscription_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/subscription",
    "commits_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/contents/{+path}",
    "compare_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/merges",
    "archive_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/downloads",
    "issues_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/issues{/number}",
    "pulls_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/labels{/name}",
    "releases_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/releases{/id}",
    "deployments_url": "https://api.github.com/repos/mozilla-mobile/firefox-android/deployments",
    "created_at": 1659041943,
    "updated_at": "2023-03-09T13:41:50Z",
    "pushed_at": 1678391599,
    "git_url": "git://github.com/mozilla-mobile/firefox-android.git",
    "ssh_url": "git@github.com:mozilla-mobile/firefox-android.git",
    "clone_url": "https://github.com/mozilla-mobile/firefox-android.git",
    "svn_url": "https://github.com/mozilla-mobile/firefox-android",
    "homepage": "https://www.mozilla.org/en-us/firefox/mobile/",
    "size": 402170,
    "stargazers_count": 314,
    "watchers_count": 314,
    "language": "Kotlin",
    "has_issues": false,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": false,
    "has_pages": true,
    "has_discussions": false,
    "forks_count": 112,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 79,
    "license": {
      "key": "mpl-2.0",
      "name": "Mozilla Public License 2.0",
      "spdx_id": "MPL-2.0",
      "url": "https://api.github.com/licenses/mpl-2.0",
      "node_id": "MDc6TGljZW5zZTE0"
    },
    "allow_forking": true,
    "is_template": false,
    "web_commit_signoff_required": false,
    "topics": [

    ],
    "visibility": "public",
    "forks": 112,
    "open_issues": 79,
    "watchers": 314,
    "default_branch": "main",
    "stargazers": 314,
    "master_branch": "main",
    "organization": "mozilla-mobile"
  },
  "pusher": {
    "name": "mergify[bot]",
    "email": null
  },
  "organization": {
    "login": "mozilla-mobile",
    "id": 22351667,
    "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyMzUxNjY3",
    "url": "https://api.github.com/orgs/mozilla-mobile",
    "repos_url": "https://api.github.com/orgs/mozilla-mobile/repos",
    "events_url": "https://api.github.com/orgs/mozilla-mobile/events",
    "hooks_url": "https://api.github.com/orgs/mozilla-mobile/hooks",
    "issues_url": "https://api.github.com/orgs/mozilla-mobile/issues",
    "members_url": "https://api.github.com/orgs/mozilla-mobile/members{/member}",
    "public_members_url": "https://api.github.com/orgs/mozilla-mobile/public_members{/member}",
    "avatar_url": "https://avatars.githubusercontent.com/u/22351667?v=4",
    "description": "Mozilla Mobile Applications"
  },
  "enterprise": {
    "id": 6981,
    "slug": "mozilla-corporation",
    "name": "Mozilla-Corporation",
    "node_id": "MDEwOkVudGVycHJpc2U2OTgx",
    "avatar_url": "https://avatars.githubusercontent.com/b/6981?v=4",
    "description": null,
    "website_url": null,
    "html_url": "https://github.com/enterprises/mozilla-corporation",
    "created_at": "2021-05-04T21:26:07Z",
    "updated_at": "2021-06-09T20:53:49Z"
  },
  "sender": {
    "login": "mergify[bot]",
    "id": 37929162,
    "node_id": "MDM6Qm90Mzc5MjkxNjI=",
    "avatar_url": "https://avatars.githubusercontent.com/in/10562?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/mergify%5Bbot%5D",
    "html_url": "https://github.com/apps/mergify",
    "followers_url": "https://api.github.com/users/mergify%5Bbot%5D/followers",
    "following_url": "https://api.github.com/users/mergify%5Bbot%5D/following{/other_user}",
    "gists_url": "https://api.github.com/users/mergify%5Bbot%5D/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/mergify%5Bbot%5D/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/mergify%5Bbot%5D/subscriptions",
    "organizations_url": "https://api.github.com/users/mergify%5Bbot%5D/orgs",
    "repos_url": "https://api.github.com/users/mergify%5Bbot%5D/repos",
    "events_url": "https://api.github.com/users/mergify%5Bbot%5D/events{/privacy}",
    "received_events_url": "https://api.github.com/users/mergify%5Bbot%5D/received_events",
    "type": "Bot",
    "site_admin": false
  },
  "created": false,
  "deleted": false,
  "forced": false,
  "base_ref": null,
  "compare": "https://github.com/mozilla-mobile/firefox-android/compare/da121523462a...550651142b3d",
  "commits": [
    {
      "id": "550651142b3d0edb9567f99cdb94bf154f494bfa",
      "tree_id": "735f9ff0a6ddf1c82ecf5606da3ff0f2faeac837",
      "distinct": true,
      "message": "Bug 1818802 - Update strings in the ETP settings screen.",
      "timestamp": "2023-03-09T19:53:18Z",
      "url": "https://github.com/mozilla-mobile/firefox-android/commit/550651142b3d0edb9567f99cdb94bf154f494bfa",
      "author": {
        "name": "t-p-white",
        "email": "t-p-white"
      },
      "committer": {
        "name": "mergify[bot]",
        "email": "37929162+mergify[bot]@users.noreply.github.com",
        "username": "mergify[bot]"
      },
      "added": [

      ],
      "removed": [

      ],
      "modified": [
        "fenix/app/src/main/res/values/strings.xml"
      ]
    }
  ],
  "head_commit": {
    "id": "550651142b3d0edb9567f99cdb94bf154f494bfa",
    "tree_id": "735f9ff0a6ddf1c82ecf5606da3ff0f2faeac837",
    "distinct": true,
    "message": "Bug 1818802 - Update strings in the ETP settings screen.",
    "timestamp": "2023-03-09T19:53:18Z",
    "url": "https://github.com/mozilla-mobile/firefox-android/commit/550651142b3d0edb9567f99cdb94bf154f494bfa",
    "author": {
      "name": "t-p-white",
      "email": "t-p-white"
    },
    "committer": {
      "name": "mergify[bot]",
      "email": "37929162+mergify[bot]@users.noreply.github.com",
      "username": "mergify[bot]"
    },
    "added": [

    ],
    "removed": [

    ],
    "modified": [
      "fenix/app/src/main/res/values/strings.xml"
    ]
  }
}

Response:

{"code":32000,"documentation":"https:\/\/bmo.readthedocs.io\/en\/latest\/api\/","error":1,"message":"The following errors occurred when validating input data: Missing\nproperty. => \/commits\/0\/author\/username"}
Summary: Error resolving bug 1817058 after PR merged → Error resolving bug 1818802 after PR merged
Assignee: nobody → dkl
Status: NEW → ASSIGNED
Summary: Error resolving bug 1818802 after PR merged → [GITHUB] Fall back to author.name if author.username is missing. And use committer.username as last resort.

According to https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#push, author.name is required but author.username is not required to be included in the event JSON. So no need to use the committer object as a last resort.

Summary: [GITHUB] Fall back to author.name if author.username is missing. And use committer.username as last resort. → [GITHUB] Fall back to author.name if author.username is missing
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: