elasticsearch-perl icon indicating copy to clipboard operation
elasticsearch-perl copied to clipboard

New RHEL and Perl Version, es-perl8 - json problem

Open jenswitzel opened this issue 2 years ago • 2 comments

Hi out there we changed from REHL7 to RHEL8, perl5.10 to 5.26 and unfortutately our ES-Scripts does not work anymore. Have any of you ever seen something like this before? Cheers Jens

[Tue Jul 18 13:35:42.029118 2023] [:error] [pid 108885:tid 140114583877376] [Serializer] ** encountered object '1', but neither allow_blessed, convert_blessed nor allow_tags settings are enabled (or TO_JSON/FREEZE method missing) at path_to_cpan/perl_cpan/lib/perl5/Search/Elasticsearch/Role/Serializer/JSON.pm line 41.\n, called from sub Search::Elasticsearch::Role::Client::Direct::ANON at path_to_my_script line 134. With vars: {'var' => {'valid' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ),'_shards' => {'successful' => 1,'total' => 1,'failed' => 0}}}\n [Tue Jul 18 13:53:36.405223 2023] [:error] [pid 108726:tid 140113979897600] :Apache2 IO write: (32) Broken pipe at /service-app/apps/eprints/perl_lib/EPrints/Page.pm line 78

jenswitzel avatar Jul 18 '23 12:07 jenswitzel

@jenswitzel sorry for the delay, did you solve the issue? I think this is related to some encoding issue with the allow_blessed of the JSON library. Are you building a JSON request or this error is in the HTTP response?

ezimuel avatar Jan 25 '24 11:01 ezimuel

@ezimuel yes, solved it. Due to Upgrade to RHEL8 we also upgraded to perl5.26.3 and had to fix our JSON answer. Must be something like this now:

[...]
# push result to browser
binmode( STDOUT, ":utf8" );
print header('application/json');
#  new Perl, new to_json
my $s = JSON::to_json($result, { allow_blessed => 1, allow_nonref => 1 });
print $s;
[...]

jenswitzel avatar Jan 29 '24 08:01 jenswitzel