1

I'm deploying my software (first time in a new environment) and hitting a wall almost immediately.

I have a value that is failing its HashRef validation, but every test I can think of makes it seem like it should be valid.

Attribute (store) does not pass the type constraint because: Validation failed for 'HashRef' with value MyApp::CatalystAuthStore=HASH(0x7fa98fffa590)...

Dumping that value produces a valid-looking hashref:

bless( {
     'config' => {
                   'class' => '+MyApp::CatalystAuthStore',
                   'use_userdata_from_session' => 1
                 }
   }, 'MyApp::CatalystAuthStore' )

And when I try to self-validate using Scalar::Util::Reftype, it returns 'HASH' for my value.

So if for a moment, we could rule out an issue with my code, and considering that this is occuring for the first time at deployment, what is a good way to see what part of Moose isn't working properly on my build?

Thanks!

Ryan
  • 672
  • 1
  • 6
  • 16

1 Answers1

3

HashRef specifically looks for a unblessed hash, but yours is blessed (a MyApp::CatalystAuthStore object). Maybe MyApp::CatalystAuthStore would be a more appropriate type to use? If not, you could easily create a type that accepts both blessed and unblessed hashes.

subtype 'AnyHashRef'
   => as 'Defined'
   => where { Scalar::Util::reftype($_) eq 'HASH' }
   => inline_as { "( Scalar::Util::reftype($_[1]) eq 'HASH' )" };
ikegami
  • 367,544
  • 15
  • 269
  • 518
  • I may never understand why it always worked in my test environment during development, but you are completely correct. – Ryan Dec 01 '12 at 01:23