Repository navigation
fix(params): allow zero values for required numeric fields - #4012
Merged
mandre merged 3 commits intoSep 16, 2026
Merged
Conversation
mandre
reviewed
Sep 15, 2026
mandre
left a comment
Contributor
There was a problem hiding this comment.
Nice!
One question, though. Should we add the same fix for BuildQueryString() and BuildHeaders() that also reject 0 values for numeric when the value is marked as required?
Contributor
Author
|
Thanks for the follow-up. I extended the same required numeric-zero handling to BuildQueryString and BuildHeaders, with regression coverage for both, in 9efd285. |
winiciusallan
left a comment
Contributor
There was a problem hiding this comment.
Bom trabalho, @LucasLeao18! I left a few comments inline, please see.
mandre
approved these changes
Sep 16, 2026
Contributor
|
#4013 should fix the keystone job failure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3866
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
default_limitof0)Problem
registeredlimits.CreateOpts.DefaultLimitis declared asintwithrequired:"true", andBuildRequestBodyrejects the zero value of anyrequired field. As a result the SDK fails client-side with
Missing input for argument [DefaultLimit]when creating a registered limit with adefault_limitof0, even though Keystone accepts0as a valid limit(valid range is
-1to2147483647).Solution
BuildRequestBody,BuildQueryString, andBuildHeadersno longer treat a numeric zero as missing input forfields tagged
required:"true". Zero is legitimate input for numericfields, so range validation is left to the server. Other zero values
(empty strings, nil pointers, empty structs, ...) are still rejected
client-side as before, so existing validation behavior is unchanged
everywhere else.
This implements option 1 suggested by @winiciusallan in the issue,
scoped to numeric kinds so the existing
ErrMissingInputexpectationsfor string/struct/pointer fields keep working.
Validation
TestBuildRequestBodyRequiredNumericZero(testing/params_test.go):required
intzero passes and is serialized; requiredstringemptystill returns
ErrMissingInput.TestBuildQueryStringandTestBuildHeadersto verify requirednumeric zero values are serialized while other required zero values remain
rejected.
TestCreateRegisteredLimitWithZeroDefaultLimitplus fixtures(
openstack/identity/v3/registeredlimits/testing/): end-to-end createwith
DefaultLimit: 0, asserting the request body sent on the wire.error (
Missing input for argument [DefaultLimit]) and passes after.go test ./...) passes, except the pre-existingTestNormalizePathURLfailure which also fails on a clean checkout onWindows (path/URL normalization, unrelated to this change).
go vetis clean on the touched packages, including the acceptancetest package (
-tags acceptance).TestRegisteredLimitsCRUDacceptance test with adefault_limit: 0create/assert/delete block (not run here, requires alive OpenStack cloud).