grape: Grape 1.6.1 throughs an error on `Grape::Validations::Types.group?()`

The patch upgrade from 1.6.0 to 1.6.1 is breaking on the following line for me: https://github.com/ruby-grape/grape/blob/v1.6.1/lib/grape/dsl/parameters.rb#L154

The full error is:

An error occurred while loading ./spec/riskmethods/jsonapi/validations_spec.rb.
Failure/Error:
  optional :hash, type: ::Hash, strict_hash: true do
    optional :nested
  end

NoMethodError:
  undefined method `group?' for Grape::Validations::Types:Module
# ./vendor/bundle/ruby/2.7.0/gems/grape-1.6.1/lib/grape/dsl/parameters.rb:154:in `optional'

Even though, def self.group?() is defined on Types here, I cannot call it through IRB or any other other means: https://github.com/ruby-grape/grape/blob/v1.6.1/lib/grape/validations/types.rb#L101-L108

Looking through our specs, I also find this error:

NoMethodError:
  undefined method `multiple?' for Grape::Validations::Types:Module
# ./vendor/bundle/ruby/2.7.0/gems/grape-1.6.1/lib/grape/validations/params_scope.rb:359:in `infer_coercion'

The test setup is as follows:

  1. create a RSpec support app with some endpoints and optional params e.g.
       params do
         optional :hash, type: ::Hash, strict_hash: true do
           optional :nested
         end
       end
    
       get :strict_hash do
         ...
       end
    
  2. call that endpoint in specs
  3. see error from grape 😦

PS: In my opinion, the patch update has way to many changes in it to be honest. But I also know how hard maintaining an open-source product is, so please don’t take this as a complaint!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 15 (11 by maintainers)

Most upvoted comments

Upgrading to 1.6.2 fixed the related issue https://github.com/ruby-grape/grape/issues/2218 - thank you!

1.6.2 has been released, try updating 🤞🏻

Thanks @dm1try

Sorry for the late reply, I was out all day. I’ll take a look tomorrow and let you know.

On Wed 29 Dec 2021 at 22:52 Lutz Lengemann @.***> wrote:

Thanks for working on this so fast. I will test out, if the proposed idea helps us. But I also think it is better to not have a workaround.

If you need any help with a test setup, I can see to create an app for you guys.

Cheers

— Reply to this email directly, view it on GitHub https://github.com/ruby-grape/grape/issues/2214#issuecomment-1002789168, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAHJI5ZACFNXHIJ32E5G2DUTN7I5ANCNFSM5K5S2SVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

Avertissement
 Ce message est destiné uniquement à la personne ou à l’organisation à laquelle il est adressé et il peut contenir des informations privilégiées, confidentielles ou non divulgables en vertu de la loi. Si vous n’êtes pas le destinataire du présent message ni la personne chargée de remettre le présent message à son destinataire, il vous est strictement interdit de le divulguer, de le distribuer, de le copier ou de l’utiliser de quelque façon que ce soit. Si vous avez reçu la présente communication par erreur, veuillez en aviser l’expéditeur et détruire ou effacer tous les exemplaires que vous avez reçus.
 *Warning
 *This message is intended only for the use of the individual or entity to which it is addressed, and may contain information which is privileged, confidential, proprietary or exempt from disclosure under applicable law. If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, you are strictly prohibited from disclosing, distributing, copying or in any way using this message. If you have received this communication in error, please notify the sender, and destroy and delete any copies you may have received.

@mobilutz meanwhile, as a workaround, you could put

require 'grape/eager_load'
Grape::Validations.eager_load!
Grape::Validations::Validators.eager_load!

in the spec helper

but I’m hoping for a quick fix release 😃