Skip to content

Commit

Permalink
Merge pull request #21 from mschout/bugfix/fix-scope-set-extras
Browse files Browse the repository at this point in the history
Fix set_extras so that it does not crash
  • Loading branch information
pmb0 authored Nov 21, 2023
2 parents f44b11f + 3573c51 commit d7f5b11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Sentry/Hub/Scope.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ sub set_extra ($self, $name, $value) {
}

sub set_extras ($self, $extras) {
$self->extra = { %{ $self->extra }, %{$extras} };
for my $key (%$extras) {
$self->extra->{$key} = $extras->{$key};
}
}

sub set_tag ($self, $key, $value) {
Expand Down
7 changes: 7 additions & 0 deletions t/scope.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use Sentry::Hub::Scope;
use Sentry::Severity;
use Sentry::Tracing::Span;
use Sentry::Tracing::Transaction;
use Test::Exception;
use Test::Spec;

describe 'Sentry::Hub::Scope' => sub {
Expand Down Expand Up @@ -81,6 +82,12 @@ describe 'Sentry::Hub::Scope' => sub {
is $event->{foo}, 'bar';
};
};

describe 'set_extras' => sub {
it 'set_extras should not crash' => sub {
lives_ok { Sentry::Hub::Scope->new->set_extras({ foo => 'bar' }) };
};
};
};

runtests;

0 comments on commit d7f5b11

Please sign in to comment.