Skip to content

RegisteredLimit does not allow a defaultLimit of 0 #3866

Closed

Description

@gndrmnn

What happened?

The defaultLimit field for RegisteredLimits in Gophercloud is an integer with required:true

While OpenStack permits a value of 0, Gophercloud will fail validation for the field in that case.

Gophercloud runs into this:

gophercloud/params.go

Lines 92 to 97 in 7544537

if zero {
// if the field has a 'required' tag, it can't have a zero-value
err := ErrMissingInput{}
err.Argument = f.Name
return nil, err
}

Expected behavior would be that Gophercloud permits requests containing a defaultLimit of 0 (in fact everything from -1 to 2147483647 should be valid)

See also k-orc/openstack-resource-controller#782 (comment)

Version

v2 (current)

Activity

  1. added theissue type on Jul 22, 2026
  2. gndrmnn commented on Jul 28, 2026

    @gndrmnn
    Author

    I have grepped over this repo and it appears that defaultLimit might actually be the only field in the entire API which 1) is of the type int 2) is required: true and 3) were upstream accepts a 0 as a valid value.

    So how do we even approach this? Add a new Go struct tag for this case? e.g. numericZeroAllowed: true?

  3. winiciusallan commented on Jul 28, 2026

    @winiciusallan
    Contributor

    The param.go is quite old and I'm unsure the reason for skipping the zero-value when required. This surfaces some incompatibility with the expected result. I would say that we can:

    1. Change the params.go to accept zero values
    2. Add the pointer, remove the required tag and let the API enforce.

    I personally prefer the option 1. Adding a new tag may work, but IMHO we would be putting a plaster on the real problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions