Closed SirRender00 closed 3 months ago
I would also like to ask this one. I am also trying to update branch protection and cannot send Null. Can anyone help?
Hey any update on this? There are API endpoints that are broken presently. For required arguments, values of None must be converted to null
and explicitly sent.
I'm also seeing this issue, we've had to drop down to using the requests library where API calls via ghapi error out.
I'm seeing this issue too. Running v1.0.3. python 3.10
Any updates?
I'm seeing this issue as well when using repos.update_branch_protection, since null
is valid input for some of that endpoint's parameters.
It looks like the issue stems from this statement, which drops any key-value pairs where the value is None
.
https://github.com/fastai/ghapi/blob/b77bfaebd937a3b7527b117a5e43d99bcb98b39d/ghapi/core.py#L59
I tried removing that if
condition like so:
kwargs = {k: v for k, v in kwargs.items()}
And I'm now able to use the endpoint I previously mentioned without any issues.
Your mileage may vary.
EDIT: Or, if you actually want to do this the right way, you can just remove that line entirely, since it doesn't do anything of consequence once that if
is removed. 😉
It worked for me
Chiming in to say this is still an issue, particularly for update_branch_protection
.
All of these fields accept null
on the GitHub API side, but cannot be set as such using ghapi
.
gh.repos.update_branch_protection(
...,
required_status_checks=None,
enforce_admins=None,
required_pull_request_reviews=None,
restrictions=None,
allow_force_pushes=None,
)
It appears that this method is currently unusable to unset these fields because null
is the only way to do so. In order to do so, you can use GhApi.__call__
even though it's not very nice.
gh(f"/repos/{owner}/{repo}/branches/{branch}/protection", "PUT", data=b"""
{
...
"required_status_checks": null,
"enforce_admins": null,
"required_pull_request_reviews": null,
"restrictions": null,
"allow_force_pushes": null
}
""")
This is tested working with v1.0.4
Seems like this project might be abandoned.
Personally, I've given up on this library and just wrap around the API natively with requests
or gql
. With Github API supporting versioning as a header, this library is not worth the hassle in my opinion.
Seems like this project might be abandoned.
It's definitely not abandoned. No one at-mentioned me so I didn't get notified however.
Has anyone tried the suggested approach by @raeganbarker of removing that line to check whether all tests are still passed? If so, I'm happy to make that update (or someone could do a PR).
@jph00 I made a PR. One test is failing, but it appears to require write access to the fastai/ghapi-test repo, so I think we're good. I can confirm my use case from above now works. https://github.com/fastai/ghapi/issues/81#issuecomment-1892671885
Super -- really great to have this resolved. :D
It's definitely not abandoned. No one at-mentioned me so I didn't get notified however.
What does this mean, precisely? The issue is years old, and there are only 43 issues in the entire repository. So I'd think maintainers would be looking actively at open tickets.
What does this mean, precisely?
It means a single volunteer, me, is looking after dozens of projects largely on my own, so I'd like some basic level of help from the community of people who use my work for free. Is at-mentioning me really too much to ask?
@shreve thanks for making the PR and @jph00 thanks for reviewing and landing!
Hey, I've run into an issue where I can't figure out how to send
null
as required by some endpoints by the Github API, (specifically updating branch protection). This endpoint requires parameters of typeobject or nullable
. I've triedvar=None
,var='null'
,var=''
,var={}
. All are met with aHTTP422 Error: Unprocessable Entity
(as opposed to specifying the values which work fine). Any help would be appreciated.