Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: pull request simple field head.repo schema incorrect #6

Closed
tisonkun opened this issue Nov 4, 2022 · 13 comments
Closed

Bug: pull request simple field head.repo schema incorrect #6

tisonkun opened this issue Nov 4, 2022 · 13 comments
Labels
bug Something isn't working Rest API schema schema related

Comments

@tisonkun
Copy link

tisonkun commented Nov 4, 2022

g = ... # obtain the client
prs = g.paginate(g.rest.pulls.list, owner='apache', repo='pulsar', state='open')
pr = next(prs)

gives:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.10/site-packages/githubkit/paginator.py", line 76, in __next__
    contents = self._get_next_page()
  File "/opt/homebrew/lib/python3.10/site-packages/githubkit/paginator.py", line 112, in _get_next_page
    cast(Response[List[RT]], response).parsed_data
  File "/opt/homebrew/lib/python3.10/site-packages/githubkit/response.py", line 50, in parsed_data
    return parse_raw_as(self._data_model, self._response.content)
  File "pydantic/tools.py", line 82, in pydantic.tools.parse_raw_as
  File "pydantic/tools.py", line 38, in pydantic.tools.parse_obj_as
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 7 validation errors for ParsingModel[List[githubkit.rest.models.PullRequestSimple]]
__root__ -> 27 -> head -> repo
  none is not an allowed value (type=type_error.none.not_allowed)
__root__ -> 36 -> head -> repo
  none is not an allowed value (type=type_error.none.not_allowed)
__root__ -> 39 -> head -> repo
  none is not an allowed value (type=type_error.none.not_allowed)
__root__ -> 44 -> head -> repo
  none is not an allowed value (type=type_error.none.not_allowed)
__root__ -> 67 -> head -> repo
  none is not an allowed value (type=type_error.none.not_allowed)
__root__ -> 85 -> head -> repo
  none is not an allowed value (type=type_error.none.not_allowed)
__root__ -> 94 -> head -> repo
  none is not an allowed value (type=type_error.none.not_allowed)
@tisonkun
Copy link
Author

tisonkun commented Nov 4, 2022

It looks like the head field in response can be none but the type annotation indicate it must not be none.

@yanyongyu yanyongyu added bug Something isn't working schema schema related Rest API labels Nov 4, 2022
@tisonkun
Copy link
Author

tisonkun commented Nov 4, 2022

Workaround now by passing map_func=lambda x: x.json()

@yanyongyu
Copy link
Owner

it seems like there is an error in gh rest api definition or codegen. I will take a look at your example.

@yanyongyu
Copy link
Owner

yanyongyu commented Nov 4, 2022

by the way, which client auth strategy you are using? i think the missing of repo field may caused by the permission of github app. github app can not get any repo info (include fork repos) if the app is not installed on it and the repo field will be none

@tisonkun
Copy link
Author

tisonkun commented Nov 4, 2022

FYI GitHub(TokenAuthStrategy(<Your-Personal-Token>)).

@tisonkun
Copy link
Author

tisonkun commented Nov 4, 2022

cc @yanyongyu I'd like to know whether you can reproduce the case now.

@yanyongyu
Copy link
Owner

yanyongyu commented Nov 4, 2022

yes, i can reproduce the error. the repo field missing is caused by the deletion of pr head repo (example apache/pulsar#6036)

@yanyongyu
Copy link
Owner

yanyongyu commented Nov 4, 2022

In the gh schema, the repo field of pull request head object is "$ref": "#/components/schemas/repository" and cannot be nullable. we may need to patch the schema and report the issue to github/rest-api-description

@yanyongyu
Copy link
Owner

i have created an issue github/rest-api-description#1811 related to this and make a patch to githubkit until the schema is corrected.

@tisonkun
Copy link
Author

tisonkun commented Nov 4, 2022

Cool! Yes, I think we should patch downstream here...the challenge may be preventing codegen from accidental regression (that is, you may some fix, but the codegen revert it, lol). Or if you can oversee all the commits, a manual fix can work for now.

UPDATED: It seems [tool.codegen.schema-overrides] works well. That's awesome >_<

@yanyongyu yanyongyu changed the title Paginator casting error Bug: pull request simple field head.repo schema incorrect Nov 4, 2022
@tisonkun
Copy link
Author

tisonkun commented Nov 4, 2022

Shall we have a v0.9.1 release for this fix?

@yanyongyu
Copy link
Owner

yeah, i'm bumping the version to make a new release.

@yanyongyu
Copy link
Owner

the new version of githubkit will be available after the ci complete 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Rest API schema schema related
Projects
None yet
Development

No branches or pull requests

2 participants