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: repo activity event issue comment field missing issue_url #71

Open
IkBenNiet opened this issue Dec 20, 2023 · 6 comments
Open

Bug: repo activity event issue comment field missing issue_url #71

IkBenNiet opened this issue Dec 20, 2023 · 6 comments
Labels
bug Something isn't working Rest API schema schema related

Comments

@IkBenNiet
Copy link

Kinda strange error occur when I'm trying to get events for repository. It happens in code like:

auth = TokenAuthStrategy(GITHUB_TOKEN)
gh = GitHub(auth=auth)
 async for event in gh.paginate(
        gh.rest.activity.async_list_repo_events,
        owner=owner,
        repo=repository_name,
):
    print(event.repo.name)

Error looks like:
unexpected value; permitted: <UNSET> (type=value_error.const; given={'url': 'https://api.github.com/repos/{owner}/{repo}/pulls/comments/{id}', 'pull_request_review_id': {}, 'id': {}, 'node_id': 'PRRC_', 'diff_hunk': "@@ -1154,14 +1162,14 @@ {bunch of code from pr}', 'commit_id': '', 'original_commit_id': '', 'user': {'login': '', 'id': , 'node_id': '', 'avatar_url': 'https://avatars.githubusercontent.com/u/', 'gravatar_id': '', 'url': 'https://api.github.com/users/', 'html_url': 'https://github.com/', 'followers_url': 'https://api.github.com/users/followers', 'following_url': 'https://api.github.com/users/following{/other_user}', 'gists_url': 'https://api.github.com/users/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/subscriptions', 'organizations_url': 'https://api.github.com/users/orgs', 'repos_url': 'https://api.github.com/users/repos', 'events_url': 'https://api.github.com/users/events{/privacy}', 'received_events_url': 'https://api.github.com/users/received_events', 'type': 'User', 'site_admin': False}, 'body': "", 'created_at': '2023-12-19T21:52:26Z', 'updated_at': '2023-12-19T21:52:27Z', 'html_url': 'https://github.com/owner/repo/pull/513#discussion_r', 'pull_request_url': 'https://api.github.com/repos/owner/repo/pulls/51', 'author_association': 'CONTRIBUTOR', '_links': {'self': {'href': 'https://api.github.com/repos/owner/repo/pulls/comments/143'}, 'html': {'href': 'https://github.com/owner/repo/pull/512#discussion_r14'}, 'pull_request': {'href': 'https://api.github.com/repos/owner/repo/pulls/53'}}, 'reactions': {'url': 'https://api.github.com/repos/owner/repo/pulls/comments/123/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}, 'start_line': None, 'original_start_line': None, 'start_side': None, 'line': 1167, 'original_line': 1167, 'side': 'RIGHT', 'in_reply_to_id': 1431963291, 'original_position': 97, 'position': 97, 'subject_type': 'line'}; permitted=(<UNSET>,)) __root__ -> 98 -> payload -> comment -> issue_url field required (type=value_error.missing)

I have no idea what it means. I've found some issues with similar error. You said it has been fixed in #68 .
But as you can see, I still getting it.

Is it any way to fix it?

@yanyongyu
Copy link
Owner

It seems this is a new schema error. could you please provide the example repo info?
As described in the schema provided by github, the issue_url field is required in the payload->comment. You may fire an issue to the https://github.com/github/rest-api-description repo.

Due to the schema issue-comment is used in many fields, the required field issue_url may be hard to change. Currently, you can use the raw json result from response.

@yanyongyu yanyongyu added bug Something isn't working schema schema related Rest API labels Dec 20, 2023
@yanyongyu yanyongyu changed the title Error while parsing events Bug: repo activity event issue comment field missing issue_url Dec 20, 2023
@IkBenNiet
Copy link
Author

could you please provide the example repo info?

Yes, I tried to get events from some repositories, one of it is node.js repository.

You may fire an issue to the https://github.com/github/rest-api-description repo.

I'll do it. Thanks.

Currently, you can use the raw json result from response.

Sorry, but could you give a details how can I do it in correct way? Is it smth like
gh.paginate(gh.request. ...)?

@yanyongyu
Copy link
Owner

you could provide a custom map_func to the paginator like this:

async for event_dict in gh.paginate(
    gh.rest.activity.async_list_repo_events,
    owner=owner,
    repo=repo,
    map_func=lambda resp: resp.json()
):
    ...

the default map_func is to use the resp.parsed_data to provide data validation and type hints. you can use the response.json() to get the raw json data instead.

@IkBenNiet
Copy link
Author

Thanks a lot

@IkBenNiet
Copy link
Author

async for event_dict in gh.paginate(
    gh.rest.activity.async_list_repo_events,
    owner=owner,
    repo=repo,
    map_func=lambda resp: resp.json()
):
    .

So, this code raises HTTP exception 422. If I remove map function it return to the beginning. Should I open new issue? Is it error with your lib at all?
Full traceback can be found here: https://pasty.lus.pm/ngCEz5

@yanyongyu
Copy link
Owner

I could not repreduce the error with http 422. but according to the github docs, http 422 indicates "Validation failed, or the endpoint has been spammed."

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