Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random error on grape params #2447

Closed
virgiledelplace opened this issue May 23, 2024 · 5 comments
Closed

Random error on grape params #2447

virgiledelplace opened this issue May 23, 2024 · 5 comments
Labels

Comments

@virgiledelplace
Copy link

Hi,

i have a random error with grape params (version : 1.3.0)

i have this for the params :

.....
requires :package, type: Hash, allow_blank: false do
            optional :packets, type: Array, default: [] do
              requires :weightKg, type: Float, allow_blank: false
              optional :lengthCm, type: Float, allow_blank: false
              optional :widthCm, type:Float, allow_blank: false
              optional :heightCm, type:Float, allow_blank: false
              optional :description, type: String, allow_blank: true

              at_least_one_of :volumeM3, :lengthCm
              all_or_none_of :lengthCm, :widthCm, :heightCm
            end
.....

i got an error with this payload :

{
"package": {
        "packets": [
            {
                "weightKg": 180.5,
                "volumeM3": 1,
                "lengthCm": 10,
                "widthCm": 10,
                "heightCm": 200,
                "description": "xxx : xxxx",
            }
        ]
    }
}

Error i got :

package[packets][2][volumeM3], package[packets][2][lengthCm] are missing, at least one parameter must be provided

Is very stange, because i have only one packet, its very random because with same payload on other call i dont have this error.

Thanks you for your help

@dblock
Copy link
Member

dblock commented May 23, 2024

This is a fairly old version, could you please try on HEAD (or a more recently released version)? Maybe write a test that reproduces/does not reproduce this?

@dblock dblock added the bug? label May 23, 2024
@virgiledelplace
Copy link
Author

Hmm for the moment we are blocked for the update, that why i open an issue. But i understand we need to upgrade the gem.

I already try to reproduce it in rspec, but that not work. Thanks for your response @dblock, we will try an update.

@dblock
Copy link
Member

dblock commented May 23, 2024

I already try to reproduce it in rspec, but that not work. Thanks for your response @dblock, we will try an update.

Does your spec fail on the 1.3.0 tag? I suspect it does, so I am going to close this as fixed. But feel free to comment/reopen otherwise.

@dblock dblock closed this as completed May 23, 2024
@virgiledelplace
Copy link
Author

Nop its never failed, cannot reproduce it :/

@dblock
Copy link
Member

dblock commented May 23, 2024

Nop its never failed, cannot reproduce it :/

Not even in 1.3? That's odd, no? Post a link to a 1.3 branch with your test added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants