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

MBS-13453: Avoid double-decoding some errors #3323

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/MusicBrainz/Errors.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Carp qw( croak );
use CGI::Simple::Util qw( escape );
use DBDefs;
use Devel::StackTrace;
use Encode qw( decode );
use English;
use IO::File;
use Scalar::Util qw( blessed );
Expand Down Expand Up @@ -134,8 +135,14 @@ sub sig_die_handler {
$sentry_frames{sentry_frames} = [reverse @included_frames];
}

my $stack_trace_string = $stacktrace->as_string(max_arg_length => 0);

eval {
$stack_trace_string = decode('utf-8', $stack_trace_string);
};

$stack_traces->{$message} = {
as_string => $stacktrace->as_string(max_arg_length => 0),
as_string => $stack_trace_string,
%sentry_frames,
};
}
Expand Down
3 changes: 1 addition & 2 deletions lib/MusicBrainz/Server/Connector.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use Moose;
use MusicBrainz::Server::Exceptions;
use DBIx::Connector;
use Sql;
use Encode qw( decode_utf8 );

has 'conn' => (
isa => 'DBIx::Connector',
Expand Down Expand Up @@ -56,7 +55,7 @@ sub _build_conn
my $exception = 'MusicBrainz::Server::Exceptions::DatabaseError';
$exception .= '::StatementTimedOut'
if $state eq '57014';
$exception->throw( sqlstate => $state, message => decode_utf8($msg) );
$exception->throw( sqlstate => $state, message => $msg );
reosarevok marked this conversation as resolved.
Show resolved Hide resolved
},
RaiseError => 0,
PrintError => 0,
Expand Down