octokit / webhooks.net

GitHub webhook events toolset for .NET
MIT License
49 stars 31 forks source link

[BUG]: StringEnum parsing is inconsistent #543

Open Beau-Gosse-dev opened 1 month ago

Beau-Gosse-dev commented 1 month ago

What happened?

After upgrading Octokit.Webhooks from 1.5.1 to 2.2.3 we noticed a test start failing. However it wouldn't fail when debugging. We narrowed it down to something about the way StringEnum is working.

Checking a PullRequestEvent -> Sender -> Type against Octokit.Webhooks.Models.UserType.Bot was previously correctly returning true, but now returns false. But if debugging, or if using the sender type before the check, the check returns true again. (Such as printing the value to console)

Reproduction

using System.Text.Json;
using Octokit.Webhooks.Events;

var body = await File.ReadAllTextAsync("testJson.json");

var pullRequestEvent = JsonSerializer.Deserialize<PullRequestEvent>(body);

// Uncomment this to get the expected result
//Console.WriteLine(pullRequestEvent?.Sender?.Type);
var result = pullRequestEvent?.Sender?.Type == Octokit.Webhooks.Models.UserType.Bot;

Console.WriteLine(result);
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net8.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="Octokit.Webhooks" Version="2.2.3" />
    </ItemGroup>

    <ItemGroup>
      <None Update="testJson.json">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      </None>
    </ItemGroup>
</Project>

test data:

{
  "action": "opened",
  "number": 1838,
  "pull_request": {
    "url": "https://api.github.com/repos/abc",
    "id": 1359500000,
    "node_id": "PR_kwDOEYnXec5RCHON",
    "html_url": "https://github.com/abc/pull/1838",
    "diff_url": "https://github.com/abc/pull/1838.diff",
    "patch_url": "https://github.com/abc/pull/1838.patch",
    "issue_url": "https://api.github.com/repos/abc/issues/1838",
    "number": 1838,
    "state": "open",
    "locked": false,
    "title": "chore(deps): bump Microsoft.NET.Test.Sdk from 17.0.0 to 17.6.0",
    "user": {
      "login": "dependabot[bot]",
      "id": 49699000,
      "node_id": "MDM6Qm90NDk2OTkzMzM=",
      "avatar_url": "https://avatars.githubusercontent.com/in/29110?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/dependabot%5Bbot%5D",
      "html_url": "https://github.com/apps/dependabot",
      "followers_url": "https://api.github.com/users/dependabot%5Bbot%5D/followers",
      "following_url": "https://api.github.com/users/dependabot%5Bbot%5D/following{/other_user}",
      "gists_url": "https://api.github.com/users/dependabot%5Bbot%5D/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/dependabot%5Bbot%5D/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/dependabot%5Bbot%5D/subscriptions",
      "organizations_url": "https://api.github.com/users/dependabot%5Bbot%5D/orgs",
      "repos_url": "https://api.github.com/users/dependabot%5Bbot%5D/repos",
      "events_url": "https://api.github.com/users/dependabot%5Bbot%5D/events{/privacy}",
      "received_events_url": "https://api.github.com/users/dependabot%5Bbot%5D/received_events",
      "type": "Bot",
      "site_admin": false
    },
    "body": "Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.0.0 to 17.6.0.\n<details>\n<summary>Release notes</summary>\n<p><em>Sourced from <a href=\"https://github.com/microsoft/vstest/releases\">Microsoft.NET.Test.Sdk's releases</a>.</em></p>\n<blockquote>\n<h2>v17.6.0</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest/blob/main/docs/releases.md#1760\">here</a>.</p>\n<h2>v17.6.0-preview-20230223-05</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest/blob/main/docs/releases.md#1760-preview-20230223-05\">here</a>.</p>\n<h2>v17.5.0</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest/blob/main/docs/releases.md#1750\">here</a>.</p>\n<h2>v17.5.0-preview-20221221-03</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest/blob/main/docs/releases.md#1750-preview-20221221-03\">here</a>.</p>\n<h2>v17.5.0-preview-20221003-04</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/main/docs/releases.md#1750-preview-20221003-04\">here</a>.</p>\n<h2>v17.4.1</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest/blob/main/docs/releases.md#1741\">here</a>.</p>\n<h2>v17.4.0</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/main/docs/releases.md#1740\">here</a>.</p>\n<h2>v17.4.0-preview-20221003-03</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/main/docs/releases.md#1740-preview-20221003-03\">here</a>.</p>\n<h2>v17.4.0-preview-20220726-02</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/main/docs/releases.md#1740-preview-20220726-02\">here</a>.</p>\n<h2>v17.4.0-preview-20220707-01</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/master/docs/releases.md#1740-preview-20220707-01\">here</a>.</p>\n<h2>v17.3.3</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest/blob/main/docs/releases.md#1733\">here</a>.</p>\n<h2>v17.3.2</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/main/docs/releases.md#1732\">here</a>.</p>\n<h2>v17.3.1</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/main/docs/releases.md#1731\">here</a>.</p>\n<h2>v17.3.0</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/main/docs/releases.md#1730\">here</a>.</p>\n<h2>v17.3.0-preview-20220612-01</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/master/docs/releases.md#1730-preview-20220612-01\">here</a>.</p>\n<h2>v17.3.0-preview-20220530-08</h2>\n<p>See the release notes <a href=\"https://github.com/microsoft/vstest-docs/blob/master/docs/releases.md#1730-preview-20220530-08\">here</a>.</p>\n<h2>v17.3.0-preview-20220426-02</h2>\n<!-- raw HTML omitted -->\n</blockquote>\n<p>... (truncated)</p>\n</details>\n<details>\n<summary>Changelog</summary>\n<p><em>Sourced from <a href=\"https://github.com/microsoft/vstest/blob/main/docs/releases.md\">Microsoft.NET.Test.Sdk's changelog</a>.</em></p>\n<blockquote>\n<h2>17.6.0</h2>\n<h3>Issues Fixed</h3>\n<ul>\n<li>Add legacy feeds</li>\n<li>[rel/17.6] Fix Newtonsoft versions in testhost.deps.json <a href=\"https://redirect.github.com/microsoft/vstest/pull/4372\">#4372</a></li>\n<li>Revert &quot;Revert &quot;Fix signature verification&quot; (<a href=\"https://redirect.github.com/microsoft/vstest/issues/4333\">#4333</a>&quot; <a href=\"https://redirect.github.com/microsoft/vstest/pull/4345\">#4345</a></li>\n<li>Revert &quot;Fix signature verification&quot; <a href=\"https://redirect.github.com/microsoft/vstest/pull/4333\">#4333</a></li>\n<li>Fix signature verification <a href=\"https://redirect.github.com/microsoft/vstest/pull/4331\">#4331</a></li>\n<li>Pre-start testhosts <a href=\"https://redirect.github.com/microsoft/vstest/pull/3666\">#3666</a></li>\n<li>Add <code>dotnet vstest</code> deprecation message <a href=\"https://redirect.github.com/microsoft/vstest/pull/4297\">#4297</a></li>\n<li>Catch unhandled exception and avoid crash on test host exit <a href=\"https://redirect.github.com/microsoft/vstest/pull/4291\">#4291</a></li>\n<li>Remove chutzpah <a href=\"https://redirect.github.com/microsoft/vstest/pull/4249\">#4249</a></li>\n<li>Fix string conversion of <code>Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome</code> <a href=\"https://redirect.github.com/microsoft/vstest/pull/4243\">#4243</a></li>\n<li>Fix potential trx logger NRE <a href=\"https://redirect.github.com/microsoft/vstest/pull/4240\">#4240</a></li>\n<li>handle object disposed exception <a href=\"https://redirect.github.com/microsoft/vstest/pull/4221\">#4221</a></li>\n<li>Added support for checking testhost compatibility with test sessions <a href=\"https://redirect.github.com/microsoft/vstest/pull/4199\">#4199</a></li>\n</ul>\n<p>See full log <a href=\"https://github.com/microsoft/vstest/compare/v17.5.0...v17.6.0\">here</a></p>\n<h3>Artifacts</h3>\n<ul>\n<li>TestPlatform vsix: <a href=\"https://vsdrop.corp.microsoft.com/file/v1/Products/DevDiv/microsoft/vstest/17.6/20230515-01;/TestPlatform.vsix\">17.6.0</a></li>\n<li>Microsoft.TestPlatform.ObjectModel : <a href=\"https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.6.0\">17.6.0</a></li>\n</ul>\n<h2>17.3.3</h2>\n<h3>Issues Fixed</h3>\n<ul>\n<li>[rel/17.3] Update Newtonsoft.Json to 13.0.1 <a href=\"https://redirect.github.com/microsoft/vstest/pull/4299\">#4299</a></li>\n</ul>\n<p>See full log <a href=\"https://github.com/microsoft/vstest/compare/v17.3.2...v17.3.3\">here</a></p>\n<h3>Drops</h3>\n<ul>\n<li>TestPlatform vsix: <a href=\"https://vsdrop.corp.microsoft.com/file/v1/Products/DevDiv/microsoft/vstest/17.3/20230324-03;/TestPlatform.vsix\">17.3.3</a></li>\n<li>Microsoft.TestPlatform.ObjectModel : <a href=\"https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.3.3\">17.3.3</a></li>\n</ul>\n<h2>17.2.1</h2>\n<h3>Issues Fixed</h3>\n<ul>\n<li>[rel/17.2] Update Newtonsoft.Json to 13.0.1 <a href=\"https://redirect.github.com/microsoft/vstest/pull/4310\">#4310</a></li>\n</ul>\n<p>See full log <a href=\"https://github.com/microsoft/vstest/compare/v17.2.0...v17.2.1\">here</a></p>\n<h3>Drops</h3>\n<ul>\n<li>TestPlatform vsix: <a href=\"https://vsdrop.corp.microsoft.com/file/v1/Products/DevDiv/microsoft/vstest/17.2/20230324-02;/TestPlatform.vsix\">17.2.1</a></li>\n<li>Microsoft.TestPlatform.ObjectModel : <a href=\"https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.2.1\">17.2.1</a></li>\n</ul>\n<!-- raw HTML omitted -->\n</blockquote>\n<p>... (truncated)</p>\n</details>\n<details>\n<summary>Commits</summary>\n<ul>\n<li><a href=\"https://github.com/microsoft/vstest/commit/44971e4bd478e353dd2fbaea5b355f4bcab95a35\"><code>44971e4</code></a> Add legacy feeds</li>\n<li><a href=\"https://github.com/microsoft/vstest/commit/7933ee32f416745e48ff33cb6a3e82fd1ca38b87\"><code>7933ee3</code></a> [rel/17.6] Fix Newtonsoft versions in testhost.deps.json (<a href=\"https://redirect.github.com/microsoft/vstest/issues/4372\">#4372</a>)</li>\n<li><a href=\"https://github.com/microsoft/vstest/commit/5bef4cdc79ad79f5627c028b6cf06a4197aa9c54\"><code>5bef4cd</code></a> Update dependencies from <a href=\"https://dev.azure.com/devdiv/DevDiv/_git/vs-code-cov\">https://dev.azure.com/devdiv/DevDiv/_git/vs-code-cov</a>...</li>\n<li><a href=\"https://github.com/microsoft/vstest/commit/7f76aac92f152f91555175b7a73cf7391fa6ce8c\"><code>7f76aac</code></a> Update dependencies from <a href=\"https://dev.azure.com/devdiv/DevDiv/_git/vs-code-cov\">https://dev.azure.com/devdiv/DevDiv/_git/vs-code-cov</a>...</li>\n<li><a href=\"https://github.com/microsoft/vstest/commit/2d656fe2133f89248825419fb8ffac5505486906\"><code>2d656fe</code></a> Revert &quot;Revert &quot;Fix signature verification&quot; (<a href=\"https://redirect.github.com/microsoft/vstest/issues/4333\">#4333</a>&quot; (<a href=\"https://redirect.github.com/microsoft/vstest/issues/4345\">#4345</a></li>\n<li><a href=\"https://github.com/microsoft/vstest/commit/b9dfa22788993bae967d21cb98933e3e5a1738bf\"><code>b9dfa22</code></a> Revert &quot;Fix signature verification&quot; (<a href=\"https://redirect.github.com/microsoft/vstest/issues/4333\">#4333</a></li>\n<li><a href=\"https://github.com/microsoft/vstest/commit/36f34b6de6f40c67c79b5db46908cfa6fdfea4d9\"><code>36f34b6</code></a> Fix signature verification (<a href=\"https://redirect.github.com/microsoft/vstest/issues/4331\">#4331</a>)</li>\n<li><a href=\"https://github.com/microsoft/vstest/commit/80be5e8b0a24f617dc70edeb9866efc64f939e2b\"><code>80be5e8</code></a> [main] Update dependencies from devdiv/DevDiv/vs-code-coverage (<a href=\"https://redirect.github.com/microsoft/vstest/issues/4322\">#4322</a>)Co-auth...</li>\n<li><a href=\"https://github.com/microsoft/vstest/commit/05c0c4c4f084782533443dfeae0f6627018c5b6a\"><code>05c0c4c</code></a> Pre-start testhosts (<a href=\"https://redirect.github.com/microsoft/vstest/issues/3666\">#3666</a>)</li>\n<li><a href=\"https://github.com/microsoft/vstest/commit/3990c633bcf933291f40d44c0b7586c3a6e89d55\"><code>3990c63</code></a> Update releases.md (<a href=\"https://redirect.github.com/microsoft/vstest/issues/4321\">#4321</a>)</li>\n<li>Additional commits viewable in <a href=\"https://github.com/microsoft/vstest/compare/v17.0.0...v17.6.0\">compare view</a></li>\n</ul>\n</details>\n<br />\n\n\n[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.NET.Test.Sdk&package-manager=nuget&previous-version=17.0.0&new-version=17.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)\n\nDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.\n\n[//]: # (dependabot-automerge-start)\n[//]: # (dependabot-automerge-end)\n\n---\n\n<details>\n<summary>Dependabot commands and options</summary>\n<br />\n\nYou can trigger Dependabot actions by commenting on this PR:\n- `@dependabot rebase` will rebase this PR\n- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it\n- `@dependabot merge` will merge this PR after your CI passes on it\n- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it\n- `@dependabot cancel merge` will cancel a previously requested merge and block automerging\n- `@dependabot reopen` will reopen this PR if it is closed\n- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually\n- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)\n- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)\n- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)\n\n\n</details>",
    "created_at": "2023-05-22T15:58:49Z",
    "updated_at": "2023-05-22T15:58:49Z",
    "closed_at": null,
    "merged_at": null,
    "merge_commit_sha": null,
    "assignee": null,
    "assignees": [

    ],
    "requested_reviewers": [

    ],
    "requested_teams": [

    ],
    "labels": [

    ],
    "milestone": null,
    "draft": false,
    "commits_url": "https://api.github.com/repos/abc/pulls/1838/commits",
    "review_comments_url": "https://api.github.com/repos/abc/pulls/1838/comments",
    "review_comment_url": "https://api.github.com/repos/abc/pulls/comments{/number}",
    "comments_url": "https://api.github.com/repos/abc/issues/1838/comments",
    "statuses_url": "https://api.github.com/repos/abc/statuses/da8262cfe23edf502a7d87f014a4960b4468996f",
    "head": {
      "label": "abc:dependabot/nuget/tests/ABC.Client.UnitTests/Microsoft.NET.Test.Sdk-17.6.0",
      "ref": "dependabot/nuget/tests/ABC.Client.UnitTests/Microsoft.NET.Test.Sdk-17.6.0",
      "sha": "da8262cfe23edf502a7d87f014a4960b44000000",
      "user": {
        "login": "abcuser",
        "id": 2232000,
        "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyMz00000=",
        "avatar_url": "https://avatars.githubusercontent.com/u/2232000?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/abc",
        "html_url": "https://github.com/abc",
        "followers_url": "https://api.github.com/users/abc/followers",
        "following_url": "https://api.github.com/users/abc/following{/other_user}",
        "gists_url": "https://api.github.com/users/abc/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/abc/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/abc/subscriptions",
        "organizations_url": "https://api.github.com/users/abc/orgs",
        "repos_url": "https://api.github.com/users/abc/repos",
        "events_url": "https://api.github.com/users/abc/events{/privacy}",
        "received_events_url": "https://api.github.com/users/abc/received_events",
        "type": "Organization",
        "site_admin": false
      },
      "repo": {
        "id": 294246265,
        "node_id": "MDEwOlJlcG9zaXRvcnky000000YyNjU=",
        "name": "abc-123",
        "full_name": "abc",
        "private": false,
        "owner": {
          "login": "abc",
          "id": 2232217,
          "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyMzIyMTc=",
          "avatar_url": "https://avatars.githubusercontent.com/u/2232217?v=4",
          "gravatar_id": "",
          "url": "https://api.github.com/users/abc",
          "html_url": "https://github.com/abc",
          "followers_url": "https://api.github.com/users/abc/followers",
          "following_url": "https://api.github.com/users/abc/following{/other_user}",
          "gists_url": "https://api.github.com/users/abc/gists{/gist_id}",
          "starred_url": "https://api.github.com/users/abc/starred{/owner}{/repo}",
          "subscriptions_url": "https://api.github.com/users/abc/subscriptions",
          "organizations_url": "https://api.github.com/users/abc/orgs",
          "repos_url": "https://api.github.com/users/abc/repos",
          "events_url": "https://api.github.com/users/abc/events{/privacy}",
          "received_events_url": "https://api.github.com/users/abc/received_events",
          "type": "Organization",
          "site_admin": false
        },
        "html_url": "https://github.com/abc",
        "description": "The aaa abc123 ",
        "fork": false,
        "url": "https://api.github.com/repos/abc",
        "forks_url": "https://api.github.com/repos/abc/forks",
        "keys_url": "https://api.github.com/repos/abc/keys{/key_id}",
        "collaborators_url": "https://api.github.com/repos/abc/collaborators{/collaborator}",
        "teams_url": "https://api.github.com/repos/abc/teams",
        "hooks_url": "https://api.github.com/repos/abc/hooks",
        "issue_events_url": "https://api.github.com/repos/abc/issues/events{/number}",
        "events_url": "https://api.github.com/repos/abc/events",
        "assignees_url": "https://api.github.com/repos/abc/assignees{/user}",
        "branches_url": "https://api.github.com/repos/abc/branches{/branch}",
        "tags_url": "https://api.github.com/repos/abc/tags",
        "blobs_url": "https://api.github.com/repos/abc/git/blobs{/sha}",
        "git_tags_url": "https://api.github.com/repos/abc/git/tags{/sha}",
        "git_refs_url": "https://api.github.com/repos/abc/git/refs{/sha}",
        "trees_url": "https://api.github.com/repos/abc/git/trees{/sha}",
        "statuses_url": "https://api.github.com/repos/abc/statuses/{sha}",
        "languages_url": "https://api.github.com/repos/abc/languages",
        "stargazers_url": "https://api.github.com/repos/abc/stargazers",
        "contributors_url": "https://api.github.com/repos/abc/contributors",
        "subscribers_url": "https://api.github.com/repos/abc/subscribers",
        "subscription_url": "https://api.github.com/repos/abc/subscription",
        "commits_url": "https://api.github.com/repos/abc/commits{/sha}",
        "git_commits_url": "https://api.github.com/repos/abc/git/commits{/sha}",
        "comments_url": "https://api.github.com/repos/abc/comments{/number}",
        "issue_comment_url": "https://api.github.com/repos/abc/issues/comments{/number}",
        "contents_url": "https://api.github.com/repos/abc/contents/{+path}",
        "compare_url": "https://api.github.com/repos/abc/compare/{base}...{head}",
        "merges_url": "https://api.github.com/repos/abc/merges",
        "archive_url": "https://api.github.com/repos/abc/{archive_format}{/ref}",
        "downloads_url": "https://api.github.com/repos/abc/downloads",
        "issues_url": "https://api.github.com/repos/abc/issues{/number}",
        "pulls_url": "https://api.github.com/repos/abc/pulls{/number}",
        "milestones_url": "https://api.github.com/repos/abc/milestones{/number}",
        "notifications_url": "https://api.github.com/repos/abc/notifications{?since,all,participating}",
        "labels_url": "https://api.github.com/repos/abc/labels{/name}",
        "releases_url": "https://api.github.com/repos/abc/releases{/id}",
        "deployments_url": "https://api.github.com/repos/abc/deployments",
        "created_at": "2020-09-09T22:46:47Z",
        "updated_at": "2023-03-13T11:20:07Z",
        "pushed_at": "2023-05-22T15:58:50Z",
        "git_url": "git://github.com/abc.git",
        "ssh_url": "git@github.com:abc.git",
        "clone_url": "https://github.com/abc.git",
        "svn_url": "https://github.com/abc",
        "homepage": "https://abc.amazon.com/aaa-abc123-dotnet/",
        "size": 40796,
        "stargazers_count": 136,
        "watchers_count": 136,
        "language": "C#",
        "has_issues": true,
        "has_projects": true,
        "has_downloads": true,
        "has_wiki": true,
        "has_pages": false,
        "has_discussions": true,
        "forks_count": 31,
        "mirror_url": null,
        "archived": false,
        "disabled": false,
        "open_issues_count": 58,
        "license": {
          "key": "apache-2.0",
          "name": "Apache License 2.0",
          "spdx_id": "Apache-2.0",
          "url": "https://api.github.com/licenses/apache-2.0",
          "node_id": "MDc6TGljZW5zZTI="
        },
        "allow_forking": true,
        "is_template": false,
        "web_commit_signoff_required": false,
        "topics": [
          "analyzer",
          "abc",
          "csharp",
          "dotnet-core"
        ],
        "visibility": "public",
        "forks": 31,
        "open_issues": 58,
        "watchers": 136,
        "default_branch": "main",
        "allow_squash_merge": true,
        "allow_merge_commit": true,
        "allow_rebase_merge": true,
        "allow_auto_merge": false,
        "delete_branch_on_merge": true,
        "allow_update_branch": false,
        "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"
      }
    },
    "base": {
      "label": "abc:main",
      "ref": "main",
      "sha": "05fb3662f25a6ee6647f04e15ac20137ba56fe82",
      "user": {
        "login": "abc",
        "id": 2232217,
        "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyMzIyMTc=",
        "avatar_url": "https://avatars.githubusercontent.com/u/2232217?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/abc",
        "html_url": "https://github.com/abc",
        "followers_url": "https://api.github.com/users/abc/followers",
        "following_url": "https://api.github.com/users/abc/following{/other_user}",
        "gists_url": "https://api.github.com/users/abc/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/abc/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/abc/subscriptions",
        "organizations_url": "https://api.github.com/users/abc/orgs",
        "repos_url": "https://api.github.com/users/abc/repos",
        "events_url": "https://api.github.com/users/abc/events{/privacy}",
        "received_events_url": "https://api.github.com/users/abc/received_events",
        "type": "Organization",
        "site_admin": false
      },
      "repo": {
        "id": 294246265,
        "node_id": "MDEwOlJlcG9zaXRvcnkyOTQyNDYyNjU=",
        "name": "aaa-abc123-dotnet-client",
        "full_name": "abc",
        "private": false,
        "owner": {
          "login": "abc",
          "id": 2232217,
          "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyMzIyMTc=",
          "avatar_url": "https://avatars.githubusercontent.com/u/2232217?v=4",
          "gravatar_id": "",
          "url": "https://api.github.com/users/abc",
          "html_url": "https://github.com/abc",
          "followers_url": "https://api.github.com/users/abc/followers",
          "following_url": "https://api.github.com/users/abc/following{/other_user}",
          "gists_url": "https://api.github.com/users/abc/gists{/gist_id}",
          "starred_url": "https://api.github.com/users/abc/starred{/owner}{/repo}",
          "subscriptions_url": "https://api.github.com/users/abc/subscriptions",
          "organizations_url": "https://api.github.com/users/abc/orgs",
          "repos_url": "https://api.github.com/users/abc/repos",
          "events_url": "https://api.github.com/users/abc/events{/privacy}",
          "received_events_url": "https://api.github.com/users/abc/received_events",
          "type": "Organization",
          "site_admin": false
        },
        "html_url": "https://github.com/abc",
        "description": "The ",
        "fork": false,
        "url": "https://api.github.com/repos/abc",
        "forks_url": "https://api.github.com/repos/abc/forks",
        "keys_url": "https://api.github.com/repos/abc/keys{/key_id}",
        "collaborators_url": "https://api.github.com/repos/abc/collaborators{/collaborator}",
        "teams_url": "https://api.github.com/repos/abc/teams",
        "hooks_url": "https://api.github.com/repos/abc/hooks",
        "issue_events_url": "https://api.github.com/repos/abc/issues/events{/number}",
        "events_url": "https://api.github.com/repos/abc/events",
        "assignees_url": "https://api.github.com/repos/abc/assignees{/user}",
        "branches_url": "https://api.github.com/repos/abc/branches{/branch}",
        "tags_url": "https://api.github.com/repos/abc/tags",
        "blobs_url": "https://api.github.com/repos/abc/git/blobs{/sha}",
        "git_tags_url": "https://api.github.com/repos/abc/git/tags{/sha}",
        "git_refs_url": "https://api.github.com/repos/abc/git/refs{/sha}",
        "trees_url": "https://api.github.com/repos/abc/git/trees{/sha}",
        "statuses_url": "https://api.github.com/repos/abc/statuses/{sha}",
        "languages_url": "https://api.github.com/repos/abc/languages",
        "stargazers_url": "https://api.github.com/repos/abc/stargazers",
        "contributors_url": "https://api.github.com/repos/abc/contributors",
        "subscribers_url": "https://api.github.com/repos/abc/subscribers",
        "subscription_url": "https://api.github.com/repos/abc/subscription",
        "commits_url": "https://api.github.com/repos/abc/commits{/sha}",
        "git_commits_url": "https://api.github.com/repos/abc/git/commits{/sha}",
        "comments_url": "https://api.github.com/repos/abc/comments{/number}",
        "issue_comment_url": "https://api.github.com/repos/abc/issues/comments{/number}",
        "contents_url": "https://api.github.com/repos/abc/contents/{+path}",
        "compare_url": "https://api.github.com/repos/abc/compare/{base}...{head}",
        "merges_url": "https://api.github.com/repos/abc/merges",
        "archive_url": "https://api.github.com/repos/abc/{archive_format}{/ref}",
        "downloads_url": "https://api.github.com/repos/abc/downloads",
        "issues_url": "https://api.github.com/repos/abc/issues{/number}",
        "pulls_url": "https://api.github.com/repos/abc/pulls{/number}",
        "milestones_url": "https://api.github.com/repos/abc/milestones{/number}",
        "notifications_url": "https://api.github.com/repos/abc/notifications{?since,all,participating}",
        "labels_url": "https://api.github.com/repos/abc/labels{/name}",
        "releases_url": "https://api.github.com/repos/abc/releases{/id}",
        "deployments_url": "https://api.github.com/repos/abc/deployments",
        "created_at": "2020-09-09T22:46:47Z",
        "updated_at": "2023-03-13T11:20:07Z",
        "pushed_at": "2023-05-22T15:58:50Z",
        "git_url": "git://github.com/abc.git",
        "ssh_url": "git@github.com:abc.git",
        "clone_url": "https://github.com/abc.git",
        "svn_url": "https://github.com/abc",
        "homepage": "https://abc.amazon.com/aaa-abc123-dotnet/",
        "size": 40796,
        "stargazers_count": 136,
        "watchers_count": 136,
        "language": "C#",
        "has_issues": true,
        "has_projects": true,
        "has_downloads": true,
        "has_wiki": true,
        "has_pages": false,
        "has_discussions": true,
        "forks_count": 31,
        "mirror_url": null,
        "archived": false,
        "disabled": false,
        "open_issues_count": 58,
        "license": {
          "key": "apache-2.0",
          "name": "Apache License 2.0",
          "spdx_id": "Apache-2.0",
          "url": "https://api.github.com/licenses/apache-2.0",
          "node_id": "MDc6TGljZW5zZTI="
        },
        "allow_forking": true,
        "is_template": false,
        "web_commit_signoff_required": false,
        "topics": [
          "analyzer",
          "abc",
          "csharp",
          "dotnet-core"
        ],
        "visibility": "public",
        "forks": 31,
        "open_issues": 58,
        "watchers": 136,
        "default_branch": "main",
        "allow_squash_merge": true,
        "allow_merge_commit": true,
        "allow_rebase_merge": true,
        "allow_auto_merge": false,
        "delete_branch_on_merge": true,
        "allow_update_branch": false,
        "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"
      }
    },
    "_links": {
      "self": {
        "href": "https://api.github.com/repos/abc/pulls/1838"
      },
      "html": {
        "href": "https://github.com/abc/pull/1838"
      },
      "issue": {
        "href": "https://api.github.com/repos/abc/issues/1838"
      },
      "comments": {
        "href": "https://api.github.com/repos/abc/issues/1838/comments"
      },
      "review_comments": {
        "href": "https://api.github.com/repos/abc/pulls/1838/comments"
      },
      "review_comment": {
        "href": "https://api.github.com/repos/abc/pulls/comments{/number}"
      },
      "commits": {
        "href": "https://api.github.com/repos/abc/pulls/1838/commits"
      },
      "statuses": {
        "href": "https://api.github.com/repos/abc/statuses/da7d87f014a4960b4468996f"
      }
    },
    "author_association": "CONTRIBUTOR",
    "auto_merge": null,
    "active_lock_reason": null,
    "merged": false,
    "mergeable": null,
    "rebaseable": null,
    "mergeable_state": "unknown",
    "merged_by": null,
    "comments": 0,
    "review_comments": 0,
    "maintainer_can_modify": false,
    "commits": 1,
    "additions": 2,
    "deletions": 2,
    "changed_files": 1
  },
  "repository": {
    "id": 294246265,
    "node_id": "MDEwOlJlcG9zaXRvcnkyOT=",
    "name": "aaa-abc123-dotnet-client",
    "full_name": "abc",
    "private": false,
    "owner": {
      "login": "abc",
      "id": 2232217,
      "node_id": "MDEyOk9yZ2FuaXphdGlvbj=",
      "avatar_url": "https://avatars.githubusercontent.com/u/2217?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/abc",
      "html_url": "https://github.com/abc",
      "followers_url": "https://api.github.com/users/abc/followers",
      "following_url": "https://api.github.com/users/abc/following{/other_user}",
      "gists_url": "https://api.github.com/users/abc/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/abc/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/abc/subscriptions",
      "organizations_url": "https://api.github.com/users/abc/orgs",
      "repos_url": "https://api.github.com/users/abc/repos",
      "events_url": "https://api.github.com/users/abc/events{/privacy}",
      "received_events_url": "https://api.github.com/users/abc/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "html_url": "https://github.com/abc",
    "description": "abc",
    "fork": false,
    "url": "https://api.github.com/repos/abc",
    "forks_url": "https://api.github.com/repos/abc/forks",
    "keys_url": "https://api.github.com/repos/abc/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/abc/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/abc/teams",
    "hooks_url": "https://api.github.com/repos/abc/hooks",
    "issue_events_url": "https://api.github.com/repos/abc/issues/events{/number}",
    "events_url": "https://api.github.com/repos/abc/events",
    "assignees_url": "https://api.github.com/repos/abc/assignees{/user}",
    "branches_url": "https://api.github.com/repos/abc/branches{/branch}",
    "tags_url": "https://api.github.com/repos/abc/tags",
    "blobs_url": "https://api.github.com/repos/abc/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/abc/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/abc/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/abc/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/abc/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/abc/languages",
    "stargazers_url": "https://api.github.com/repos/abc/stargazers",
    "contributors_url": "https://api.github.com/repos/abc/contributors",
    "subscribers_url": "https://api.github.com/repos/abc/subscribers",
    "subscription_url": "https://api.github.com/repos/abc/subscription",
    "commits_url": "https://api.github.com/repos/abc/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/abc/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/abc/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/abc/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/abc/contents/{+path}",
    "compare_url": "https://api.github.com/repos/abc/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/abc/merges",
    "archive_url": "https://api.github.com/repos/abc/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/abc/downloads",
    "issues_url": "https://api.github.com/repos/abc/issues{/number}",
    "pulls_url": "https://api.github.com/repos/abc/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/abc/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/abc/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/abc/labels{/name}",
    "releases_url": "https://api.github.com/repos/abc/releases{/id}",
    "deployments_url": "https://api.github.com/repos/abc/deployments",
    "created_at": "2020-09-09T22:46:47Z",
    "updated_at": "2023-03-13T11:20:07Z",
    "pushed_at": "2023-05-22T15:58:50Z",
    "git_url": "git://github.com/abc.git",
    "ssh_url": "git@github.com:abc.git",
    "clone_url": "https://github.com/abc.git",
    "svn_url": "https://github.com/abc",
    "homepage": "https://abc.amazon.com/aaa-abc123-dotnet/",
    "size": 40796,
    "stargazers_count": 136,
    "watchers_count": 136,
    "language": "C#",
    "has_issues": true,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "has_discussions": true,
    "forks_count": 31,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 58,
    "license": {
      "key": "apache-2.0",
      "name": "Apache License 2.0",
      "spdx_id": "Apache-2.0",
      "url": "https://api.github.com/licenses/apache-2.0",
      "node_id": "MDc6TGljZW5zZTI="
    },
    "allow_forking": true,
    "is_template": false,
    "web_commit_signoff_required": false,
    "topics": [
      "analyzer",
      "abc",
      "csharp",
      "dotnet-core"
    ],
    "visibility": "public",
    "forks": 31,
    "open_issues": 58,
    "watchers": 136,
    "default_branch": "main"
  },
  "organization": {
    "login": "abc",
    "id": 2232217,
    "node_id": "MDEyOk9yZ2FuzIyMTc=",
    "url": "https://api.github.com/orgs/abc",
    "repos_url": "https://api.github.com/orgs/abc/repos",
    "events_url": "https://api.github.com/orgs/abc/events",
    "hooks_url": "https://api.github.com/orgs/abc/hooks",
    "issues_url": "https://api.github.com/orgs/abc/issues",
    "members_url": "https://api.github.com/orgs/abc/members{/member}",
    "public_members_url": "https://api.github.com/orgs/abc/public_members{/member}",
    "avatar_url": "https://avatars.githubusercontent.com/u/223?v=4",
    "description": ""
  },
  "enterprise": {
    "id": 1290,
    "slug": "amazon",
    "name": "Amazon",
    "node_id": "MDEwOkVudGVw",
    "avatar_url": "https://avatars.githubusercontent.com/b/1290?v=4",
    "description": "",
    "website_url": "https://www.amazon.com/",
    "html_url": "https://github.com/enterprises/amazon",
    "created_at": "2019-11-13T18:05:41Z",
    "updated_at": "2023-01-27T14:56:10Z"
  },
  "sender": {
    "login": "dependabot[bot]",
    "id": 49699333,
    "node_id": "MDM6Qm90NDk2OTkzMzM=",
    "avatar_url": "https://avatars.githubusercontent.com/in/29110?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/dependabot%5Bbot%5D",
    "html_url": "https://github.com/apps/dependabot",
    "followers_url": "https://api.github.com/users/dependabot%5Bbot%5D/followers",
    "following_url": "https://api.github.com/users/dependabot%5Bbot%5D/following{/other_user}",
    "gists_url": "https://api.github.com/users/dependabot%5Bbot%5D/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/dependabot%5Bbot%5D/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/dependabot%5Bbot%5D/subscriptions",
    "organizations_url": "https://api.github.com/users/dependabot%5Bbot%5D/orgs",
    "repos_url": "https://api.github.com/users/dependabot%5Bbot%5D/repos",
    "events_url": "https://api.github.com/users/dependabot%5Bbot%5D/events{/privacy}",
    "received_events_url": "https://api.github.com/users/dependabot%5Bbot%5D/received_events",
    "type": "Bot",
    "site_admin": false
  }
}

Versions

upgrading Octokit.Webhooks from 1.5.1 to 2.2.3

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 1 month ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

JamieMagee commented 1 month ago

Thanks for opening this. We added StringEnum<TEnum> in 2.0.0 as a safer way to parse enums, so users didn't get broken when new enum values started to be returned from the GitHub API.

I can't get your reproduction to work, but I do get a warning in my IDE of

Implicit conversion of Octokit.Webhooks.Models.UserType.Bot from UserType to StringEnum<UserType>

Which makes sense if you're hitting this line

https://github.com/octokit/webhooks.net/blob/0212aff733fcb4b2bc5badddbbda5fd18047a2be/src/Octokit.Webhooks/Extensions/StringEnum.cs#L38

I can't quite figure out why you're getting different results though, as StringEnum<TEnum> is a record, and record equality is defined as:

For records, value equality means that two variables of a record type are equal if the types match and all property and field values compare equal.

Could you maybe try pullRequestEvent?.Sender?.Type.Value to directly get the UserType enum and avoid the implicit conversion. Or pullRequestEvent?.Sender?.Type.TryParse(out var senderType) if you want to guard against potentially new user enum values.

Beau-Gosse-dev commented 1 month ago

Okay, we can probably just use .Value Thanks for looking into it.

JamieMagee commented 1 month ago

You're welcome. I'll keep this open for now to see if I can repro your original issue.