yanyongyu / githubkit

The modern, all-batteries-included GitHub SDK for Python, including rest api, graphql, webhooks, like octokit!

Home Page:https://yanyongyu.github.io/githubkit/

Repository from Github https://github.comyanyongyu/githubkitRepository from Github https://github.comyanyongyu/githubkit

Wrong schema for installation permission literal

keu opened this issue · comments

After iterating over async_list_installations_for_authenticated_user result I encountered the following error:

  File "/usr/local/lib/python3.12/site-packages/githubkit/response.py", line 94, in parsed_data

    return type_validate_json(self._data_model, self.content)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.12/site-packages/githubkit/compat.py", line 43, in type_validate_json

    return TypeAdapter(type_).validate_json(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.12/site-packages/pydantic/type_adapter.py", line 135, in wrapped

    return func(self, *args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.12/site-packages/pydantic/type_adapter.py", line 384, in validate_json

    return self.validator.validate_json(data, strict=strict, context=context)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

pydantic_core._pydantic_core.ValidationError: 2 validation errors for UserInstallationsGetResponse200

installations.0.permissions.organization_copilot_seat_management.literal[<UNSET>]

  Input should be <UNSET> [type=literal_error, input_value='read', input_type=str]

    For further information visit https://errors.pydantic.dev/2.9/v/literal_error

installations.0.permissions.organization_copilot_seat_management.literal['write']

  Input should be 'write' [type=literal_error, input_value='read', input_type=str]

    For further information visit https://errors.pydantic.dev/2.9/v/literal_error

It seems the github's schema has wrong enum values:

"organization_copilot_seat_management": {
  "type": "string",
  "description": "The level of permission to grant the access token for managing access to GitHub Copilot for members of an organization with a Copilot Business subscription. This property is in public preview and is subject to change.",
  "enum": [
    "write"
  ]
},

It seems most of the enums of the installation permissions have both read and write (or read only). but, workflows, organization_copilot_seat_management, profile only have write.

From the github docs:

We can only patch the organization_copilot_seat_management schema for now.