Skip to content

Parsing pull requests fails due to Pydantic validation (missing PullRequestSimplePropHead.label) #70

Closed
@MShekow

Description

@MShekow

If you run something like for pr in github.paginate(github.rest.pulls.list, owner="yarnpkg", repo="yarn", state="all"): ... you will get an error such as

pydantic.error_wrappers.ValidationError: 2 validation errors for ParsingModel[List[githubkit.rest.models.PullRequestSimple]] __root__ -> 31 -> head -> label none is not an allowed value (type=type_error.none.not_allowed)

because the label is missing in the response. Here is an example element contained in the response:

{
    "url": "https://api.github.com/repos/yarnpkg/yarn/pulls/1477",
    "id": 90980048,
    "node_id": "MDExOlB1bGxSZXF1ZXN0OTA5ODAwNDg=",
    "html_url": "https://github.com/yarnpkg/yarn/pull/1477",
    "diff_url": "https://github.com/yarnpkg/yarn/pull/1477.diff",
    "patch_url": "https://github.com/yarnpkg/yarn/pull/1477.patch",
    "issue_url": "https://api.github.com/repos/yarnpkg/yarn/issues/1477",
    "number": 1477,
    "state": "closed",
    "locked": false,
    "title": "fix-1158: resolve dep verions by ranges, not exact versions (#1158) (#1272) (#1404)",
    "user": {
      "login": "ghost",
      "id": 10137,
      "node_id": "MDQ6VXNlcjEwMTM3",
      "avatar_url": "https://avatars.githubusercontent.com/u/10137?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/ghost",
      "html_url": "https://github.com/ghost",
      "followers_url": "https://api.github.com/users/ghost/followers",
      "following_url": "https://api.github.com/users/ghost/following{/other_user}",
      "gists_url": "https://api.github.com/users/ghost/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/ghost/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/ghost/subscriptions",
      "organizations_url": "https://api.github.com/users/ghost/orgs",
      "repos_url": "https://api.github.com/users/ghost/repos",
      "events_url": "https://api.github.com/users/ghost/events{/privacy}",
      "received_events_url": "https://api.github.com/users/ghost/received_events",
      "type": "User",
      "site_admin": false
    },
    "body": "<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->\n\n**Summary**\n\nSmarter/looser dep version number resolving -- by range instead of exact version. ([comment and code disagree](https://github.com/yarnpkg/yarn/blob/master/src/package-request.js#L218-L220))\n\n`package-request` will resolve a package to the **highest** available version, and check if that package version has already been resolved with `package-resolver`'s **exact version match** `getExactVersionMatch`. \n\nInstead of matching the exact highest version: match satisfying resolved ranges of the requested package, and pick the highest available one, _if_ possible. _If not_ possible, continue and resolve to the highest possible version as before.\n\nhttps://github.com/yarnpkg/yarn/issues/112 originally says and tests the opposite of this. The concerns in this issue have been tested as-well and are succeeding: `npm shrinkwrap` && `yarn check`. Tests have been adapted, since the setup was largely the same.\n\n<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->\n\nResolves:\n- https://github.com/yarnpkg/yarn/issues/1158\n- https://github.com/yarnpkg/yarn/issues/1272\n- https://github.com/yarnpkg/yarn/issues/1404\n\n**Test plan**\n\n<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->\n\n```\n{\n  \"dependencies\": {\n    \"devbridge-autocomplete\": \"^1.2.26\",\n    \"jquery\": \"2.1.2\"\n  }\n}\n```\n\n```\n$ yarn install\n$ npm shrinkwrap --dev\n$ yarn check\n```\n\nOpen `yarn.lock` and see that range-matching dependencies are shared.\n",
    "created_at": "2016-10-26T10:50:52Z",
    "updated_at": "2016-11-11T19:27:28Z",
    "closed_at": "2016-10-26T15:00:13Z",
    "merged_at": "2016-10-26T15:00:13Z",
    "merge_commit_sha": "ec6a4508ad4aa748fc9ff9b2c665228bf5770696",
    "assignee": null,
    "assignees": [],
    "requested_reviewers": [],
    "requested_teams": [],
    "labels": [],
    "milestone": null,
    "draft": false,
    "commits_url": "https://api.github.com/repos/yarnpkg/yarn/pulls/1477/commits",
    "review_comments_url": "https://api.github.com/repos/yarnpkg/yarn/pulls/1477/comments",
    "review_comment_url": "https://api.github.com/repos/yarnpkg/yarn/pulls/comments{/number}",
    "comments_url": "https://api.github.com/repos/yarnpkg/yarn/issues/1477/comments",
    "statuses_url": "https://api.github.com/repos/yarnpkg/yarn/statuses/5a0e147f4b54573dc529a48a3545a7bf38ce6043",
    "head": {
      "label": null,
      "ref": "fix-1158-version-resolving",
      "sha": "5a0e147f4b54573dc529a48a3545a7bf38ce6043",
      "user": null,
      "repo": null
    },
    "base": {
      "label": "yarnpkg:master",
      "ref": "master",
      "sha": "86899fea2718dfd6da3666cca1166cbedec79f28",
      "user": {
        "login": "yarnpkg",
        "id": 22247014,
        "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyMjQ3MDE0",
        "avatar_url": "https://avatars.githubusercontent.com/u/22247014?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/yarnpkg",
        "html_url": "https://github.com/yarnpkg",
        "followers_url": "https://api.github.com/users/yarnpkg/followers",
        "following_url": "https://api.github.com/users/yarnpkg/following{/other_user}",
        "gists_url": "https://api.github.com/users/yarnpkg/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/yarnpkg/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/yarnpkg/subscriptions",
        "organizations_url": "https://api.github.com/users/yarnpkg/orgs",
        "repos_url": "https://api.github.com/users/yarnpkg/repos",
        "events_url": "https://api.github.com/users/yarnpkg/events{/privacy}",
        "received_events_url": "https://api.github.com/users/yarnpkg/received_events",
        "type": "Organization",
        "site_admin": false
      },
      "repo": {
        "id": 49970642,
        "node_id": "MDEwOlJlcG9zaXRvcnk0OTk3MDY0Mg==",
        "name": "yarn",
        "full_name": "yarnpkg/yarn",
        "private": false,
        "owner": {
          "login": "yarnpkg",
          "id": 22247014,
          "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyMjQ3MDE0",
          "avatar_url": "https://avatars.githubusercontent.com/u/22247014?v=4",
          "gravatar_id": "",
          "url": "https://api.github.com/users/yarnpkg",
          "html_url": "https://github.com/yarnpkg",
          "followers_url": "https://api.github.com/users/yarnpkg/followers",
          "following_url": "https://api.github.com/users/yarnpkg/following{/other_user}",
          "gists_url": "https://api.github.com/users/yarnpkg/gists{/gist_id}",
          "starred_url": "https://api.github.com/users/yarnpkg/starred{/owner}{/repo}",
          "subscriptions_url": "https://api.github.com/users/yarnpkg/subscriptions",
          "organizations_url": "https://api.github.com/users/yarnpkg/orgs",
          "repos_url": "https://api.github.com/users/yarnpkg/repos",
          "events_url": "https://api.github.com/users/yarnpkg/events{/privacy}",
          "received_events_url": "https://api.github.com/users/yarnpkg/received_events",
          "type": "Organization",
          "site_admin": false
        },
        "html_url": "https://github.com/yarnpkg/yarn",
        "description": "The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry",
        "fork": false,
        "url": "https://api.github.com/repos/yarnpkg/yarn",
        "forks_url": "https://api.github.com/repos/yarnpkg/yarn/forks",
        "keys_url": "https://api.github.com/repos/yarnpkg/yarn/keys{/key_id}",
        "collaborators_url": "https://api.github.com/repos/yarnpkg/yarn/collaborators{/collaborator}",
        "teams_url": "https://api.github.com/repos/yarnpkg/yarn/teams",
        "hooks_url": "https://api.github.com/repos/yarnpkg/yarn/hooks",
        "issue_events_url": "https://api.github.com/repos/yarnpkg/yarn/issues/events{/number}",
        "events_url": "https://api.github.com/repos/yarnpkg/yarn/events",
        "assignees_url": "https://api.github.com/repos/yarnpkg/yarn/assignees{/user}",
        "branches_url": "https://api.github.com/repos/yarnpkg/yarn/branches{/branch}",
        "tags_url": "https://api.github.com/repos/yarnpkg/yarn/tags",
        "blobs_url": "https://api.github.com/repos/yarnpkg/yarn/git/blobs{/sha}",
        "git_tags_url": "https://api.github.com/repos/yarnpkg/yarn/git/tags{/sha}",
        "git_refs_url": "https://api.github.com/repos/yarnpkg/yarn/git/refs{/sha}",
        "trees_url": "https://api.github.com/repos/yarnpkg/yarn/git/trees{/sha}",
        "statuses_url": "https://api.github.com/repos/yarnpkg/yarn/statuses/{sha}",
        "languages_url": "https://api.github.com/repos/yarnpkg/yarn/languages",
        "stargazers_url": "https://api.github.com/repos/yarnpkg/yarn/stargazers",
        "contributors_url": "https://api.github.com/repos/yarnpkg/yarn/contributors",
        "subscribers_url": "https://api.github.com/repos/yarnpkg/yarn/subscribers",
        "subscription_url": "https://api.github.com/repos/yarnpkg/yarn/subscription",
        "commits_url": "https://api.github.com/repos/yarnpkg/yarn/commits{/sha}",
        "git_commits_url": "https://api.github.com/repos/yarnpkg/yarn/git/commits{/sha}",
        "comments_url": "https://api.github.com/repos/yarnpkg/yarn/comments{/number}",
        "issue_comment_url": "https://api.github.com/repos/yarnpkg/yarn/issues/comments{/number}",
        "contents_url": "https://api.github.com/repos/yarnpkg/yarn/contents/{+path}",
        "compare_url": "https://api.github.com/repos/yarnpkg/yarn/compare/{base}...{head}",
        "merges_url": "https://api.github.com/repos/yarnpkg/yarn/merges",
        "archive_url": "https://api.github.com/repos/yarnpkg/yarn/{archive_format}{/ref}",
        "downloads_url": "https://api.github.com/repos/yarnpkg/yarn/downloads",
        "issues_url": "https://api.github.com/repos/yarnpkg/yarn/issues{/number}",
        "pulls_url": "https://api.github.com/repos/yarnpkg/yarn/pulls{/number}",
        "milestones_url": "https://api.github.com/repos/yarnpkg/yarn/milestones{/number}",
        "notifications_url": "https://api.github.com/repos/yarnpkg/yarn/notifications{?since,all,participating}",
        "labels_url": "https://api.github.com/repos/yarnpkg/yarn/labels{/name}",
        "releases_url": "https://api.github.com/repos/yarnpkg/yarn/releases{/id}",
        "deployments_url": "https://api.github.com/repos/yarnpkg/yarn/deployments",
        "created_at": "2016-01-19T17:39:16Z",
        "updated_at": "2023-12-19T10:07:58Z",
        "pushed_at": "2023-11-14T19:04:20Z",
        "git_url": "git://github.com/yarnpkg/yarn.git",
        "ssh_url": "git@github.com:yarnpkg/yarn.git",
        "clone_url": "https://github.com/yarnpkg/yarn.git",
        "svn_url": "https://github.com/yarnpkg/yarn",
        "homepage": "https://classic.yarnpkg.com",
        "size": 119486,
        "stargazers_count": 41274,
        "watchers_count": 41274,
        "language": "JavaScript",
        "has_issues": true,
        "has_projects": true,
        "has_downloads": true,
        "has_wiki": false,
        "has_pages": false,
        "has_discussions": false,
        "forks_count": 2919,
        "mirror_url": null,
        "archived": false,
        "disabled": false,
        "open_issues_count": 1990,
        "license": {
          "key": "other",
          "name": "Other",
          "spdx_id": "NOASSERTION",
          "url": null,
          "node_id": "MDc6TGljZW5zZTA="
        },
        "allow_forking": true,
        "is_template": false,
        "web_commit_signoff_required": false,
        "topics": [
          "javascript",
          "npm",
          "package-manager",
          "yarn"
        ],
        "visibility": "public",
        "forks": 2919,
        "open_issues": 1990,
        "watchers": 41274,
        "default_branch": "master"
      }
    },
    "_links": {
      "self": {
        "href": "https://api.github.com/repos/yarnpkg/yarn/pulls/1477"
      },
      "html": {
        "href": "https://github.com/yarnpkg/yarn/pull/1477"
      },
      "issue": {
        "href": "https://api.github.com/repos/yarnpkg/yarn/issues/1477"
      },
      "comments": {
        "href": "https://api.github.com/repos/yarnpkg/yarn/issues/1477/comments"
      },
      "review_comments": {
        "href": "https://api.github.com/repos/yarnpkg/yarn/pulls/1477/comments"
      },
      "review_comment": {
        "href": "https://api.github.com/repos/yarnpkg/yarn/pulls/comments{/number}"
      },
      "commits": {
        "href": "https://api.github.com/repos/yarnpkg/yarn/pulls/1477/commits"
      },
      "statuses": {
        "href": "https://api.github.com/repos/yarnpkg/yarn/statuses/5a0e147f4b54573dc529a48a3545a7bf38ce6043"
      }
    },
    "author_association": "NONE",
    "auto_merge": null,
    "active_lock_reason": null
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions