Closed netomi closed 1 year ago
Debugging reveals that the provided dict is parsed into a OrgsOrgPatchBody instance. There various fields are by default true, which is what i see in the output. That is a bit surprising, is there a way to update only fields provided via a dict?
I see that in the openapi definition some fields have a default value assigned to them which githubkit honors accordingly. Something I was not fully aware of. Also the behavior of Github does not seem to be always fully in sync with the openapi spec of their API, but it does not look like a problem on the side of githubkit.
githubkit will exclude unset value if it is not required and do not have a default value, as described in the schema.
I realized now that there are default values, thanks to githubkit. However I stumbled upon some weird behavior in github:
I only change the web_commit_signoff_required setting from True to False (I did my own rest requests before, that only changes single fields) for an org, but the members_can_create_private_repositories setting is automatically set to True, even though it does not have a default value specified in the schema. You can do the same thing on the web ui and it will happen as well.
It's really confusing 😂 . If you find some error in the schema, you can report it to https://github.com/github/rest-api-description or github support and open an issue/pr for githubkit. githubkit may temporarily overwrite the schema in configs and correct it.
I created a ticket here: https://github.com/github/rest-api-description/issues/2411
to get some insights on the use of default values. I did some more tests, and I dont see that default values are even considered by the github rest endpoint so its purpose in the rest spec might not match one according to openapi.
There is a cornercase I encountered, but that might be a bug.
btw. looking at go-github from google (https://github.com/google/go-github), no default values are considered when doing updates, so I assume that the intention of default values in the rest model is different to what githubkit considers, but lets wait for the clarification.
We could add exclude_unset=True
option to request body transform to exclude these values from passing to request.
I tried to use the following snippet to update a specific value in my org:
specifically, I wanted to update the web_commit_signoff_required parameter. However, when running the code, it looks like the request contains more parameters that will be updated, and this is also what I experience when looking at the GitHub Web UI. These additional properties got updated as well.
Now, I tried to understand from the code what could go possibly wrong but failed to do so. Do you have any insights what could happen here?