go-gerrit
go-gerrit copied to clipboard
Projects.SetConfig endpoint fails with 400 Bad Request due to ConfigInput.MaxObjectSizeLimit zero value not being omitted
I create TestProjectsService_SetConfig func to test SetConfig requests api fail error info: failed: 400 Bad Request Invalid application/json in request
I find ConfigInput field is MaxObjectSizeLimitInfo, change type string can be success...
Thanks for reporting.
Since the field is optional, MaxObjectSizeLimitInfo is definitely not right as it'll always be included despite the omitempty tag, while *MaxObjectSizeLimitInfo would allow the zero value to be properly omitted.
The documentation for the ConfigInput entity says:
The max object size limit of this project as a MaxObjectSizeLimitInfo entity. If set to 0, the max object size limit is removed. If not set, this setting is not updated.
The first and last paragraph suggests that *MaxObjectSizeLimitInfo would be right. However, the "if set to 0" part suggests maybe it can be a string or integer value too? To allow that, I think we'd need to use interface{} and let the user provide the desired type.
It's also possible the documentation is incorrect, though, since the example request shows a string being used:
"max_object_size_limit": "10m",
From the first look, interfae{} looks like the way to go here.
Proper inline documentation would be very useful to have to describe the possible values.
@andygrunwald It should be possible to infer the type from Gerrit's code. If ProjectInput.java is the right place to look, then using string as implemented in PR #112 looks right (and Gerrit REST API documentation needs updating).
You are right. The interface is more suitable and flexible
At 2022-05-27 20:32:38, "Dmitri Shuralyov" @.***> wrote:
Thanks for reporting.
Since the field is optional, MaxObjectSizeLimitInfo is definitely not right as it'll always be included despite the omitempty tag, while *MaxObjectSizeLimitInfo would allow the zero value to be properly omitted.
The documentation for the ConfigInput entity says:
The max object size limit of this project as a MaxObjectSizeLimitInfo entity. If set to 0, the max object size limit is removed. If not set, this setting is not updated.
The first and last paragraph suggests that *MaxObjectSizeLimitInfo would be right. However, the "if set to 0" part suggests maybe it can be a string or integer value too? To allow that, I think we'd need to use interface{} and let the user provide the desired type.
It's also possible the documentation is incorrect, though, since the example request shows a string being used:
"max_object_size_limit": "10m",
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
I found that the configinfo setting parameter does not take effect, such as State、SubmitType、Actions