Skip Menu |
 

This queue is for tickets about the DBIx-Error CPAN distribution.

Report information
The Basics
Id: 115222
Status: open
Priority: 0/
Queue: DBIx-Error

People
Owner: Nobody in particular
Requestors: ribasushi [...] leporine.io
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: An upcoming release of DBIx::Class 0.082900 will break this module
The populate section in t/20-dbic.t relies on a dubious behavior within DBIC that has been fixed as of https://github.com/dbsrgits/dbix-class/commit/ddcc02d14d0. The issues can be best illustrated with a simple example: ~/devel/dbic$ perl -I lib -I t/lib -MDBICTest -e ' my $s = DBICTest->init_schema; $s->exception_action(sub { Carp::cluck("\n\n\nI got called with $_[0]"); die @_ }); eval { $s->populate("Artist", [{ artistid => 1} ]) } ' Before ddcc02d14d0 this causes the exception_action handler to be invoked twice, but afterwards DBIC will only call it once for the final populate()-generated exception (see attachments). This behavior has been long desired by various parties, is much more correct/consistent and is unlikely to change again - that is: exception_action will not revert to being called twice. I am not including a patch, as I am not entirely sure which way you would like to go in fixing this. Please contact me for more info if a solution is not forthcoming. Cheers, and sorry for the trouble.
Subject: as_of_ddcc02d14d0
Download as_of_ddcc02d14d0
application/octet-stream 1.4k

Message body not shown because it is not plain text.

Subject: before_ddcc02d14d0
Download before_ddcc02d14d0
application/octet-stream 3.5k

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #115222] An upcoming release of DBIx::Class 0.082900 will break this module
Date: Fri, 10 Jun 2016 16:20:56 +0100
To: bug-DBIx-Error [...] rt.cpan.org
From: Michael Brown <mbrown [...] fensystems.co.uk>
Download (untitled) / with headers
text/plain 927b
On 09/06/16 23:45, Peter Rabbitson via RT wrote: Show quoted text
> Before ddcc02d14d0 this causes the exception_action handler to be invoked twice, but afterwards DBIC will only call it once for the final populate()-generated exception (see attachments). > > This behavior has been long desired by various parties, is much more correct/consistent and is unlikely to change again - that is: exception_action will not revert to being called twice. > > I am not including a patch, as I am not entirely sure which way you would like to go in fixing this. Please contact me for more info if a solution is not forthcoming.
Thanks for letting me know. I'm afraid I don't really understand the problem you're describing. As far as I can tell, DBIx::Error does not currently rely on exception_action being called twice. What failure have you observed when running DBIx::Error's unit tests with DBIx::Class commit ddcc02d14d0? Thanks, Michael
Download (untitled) / with headers
text/plain 741b
On Fri Jun 10 17:21:21 2016, MCB wrote: Show quoted text
> Thanks for letting me know. I'm afraid I don't really understand the > problem you're describing. As far as I can tell, DBIx::Error does not > currently rely on exception_action being called twice. What failure > have you observed when running DBIx::Error's unit tests with > DBIx::Class > commit ddcc02d14d0?
You are correct I should have been more descriptive, sorry about that ;) DBIx::Error's DBIC test relies on a specific sequence of "error-saves-and-retrieves" to happen. In order to demonstrate this best I added a similar Carp::cluck() call to your code, and attached the diff and the before/after results to my reply. Please let me know if this is sufficient to understand the issue.
Subject: dbix_error_20dbic.t_before_ddcc02d1.txt
rabbit@Ahasver:~/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1$ prove -I/home/rabbit/devel/dbic/lib -l t/20-dbic.t t/20-dbic.t .. 1/? I got called with DBIx::Error::UniqueViolation=HASH(0x36bf9e0) at /home/rabbit/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1/lib/DBIx/Error.pm line 309. DBIx::Error::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1087 eval {...} called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1108 DBIx::Class::Schema::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 112 DBIx::Class::Storage::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 177 DBIx::Class::Storage::BlockRunner::__ANON__() called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Context/Preserve.pm line 27 Context::Preserve::preserve_context() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 206 DBIx::Class::Storage::BlockRunner::_run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 105 DBIx::Class::Storage::BlockRunner::run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 186 DBIx::Class::Storage::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 867 DBIx::Class::Storage::DBI::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 654 DBIx::Class::Schema::txn_do() called at t/20-dbic.t line 38 Test::Exception::throws_ok() called at t/20-dbic.t line 39 I got called with DBIx::Error::NotNullViolation=HASH(0x36157a0) at /home/rabbit/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1/lib/DBIx/Error.pm line 309. DBIx::Error::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1087 eval {...} called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1108 DBIx::Class::Schema::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 112 DBIx::Class::Storage::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 177 DBIx::Class::Storage::BlockRunner::__ANON__() called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Context/Preserve.pm line 27 Context::Preserve::preserve_context() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 206 DBIx::Class::Storage::BlockRunner::_run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 105 DBIx::Class::Storage::BlockRunner::run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 186 DBIx::Class::Storage::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 867 DBIx::Class::Storage::DBI::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 654 DBIx::Class::Schema::txn_do() called at t/20-dbic.t line 47 Test::Exception::throws_ok() called at t/20-dbic.t line 48 I got called with execute_for_fetch() aborted with 'PRIMARY KEY must be unique' at populate slice: { id => 1, name => "You" } at /home/rabbit/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1/lib/DBIx/Error.pm line 309. DBIx::Error::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1087 eval {...} called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1108 DBIx::Class::Schema::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 112 DBIx::Class::Storage::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 2382 DBIx::Class::Storage::DBI::_dbh_execute_for_fetch() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 2270 DBIx::Class::Storage::DBI::_insert_bulk() called at /home/rabbit/devel/dbic/lib/DBIx/Class/ResultSet.pm line 2435 DBIx::Class::ResultSet::populate() called at t/20-dbic.t line 57 main::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 130 DBIx::Class::Storage::BlockRunner::try {...} () called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Try/Tiny.pm line 92 eval {...} called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Try/Tiny.pm line 83 Try::Tiny::try() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 134 DBIx::Class::Storage::BlockRunner::__ANON__() called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Context/Preserve.pm line 22 Context::Preserve::preserve_context() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 206 DBIx::Class::Storage::BlockRunner::_run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 105 DBIx::Class::Storage::BlockRunner::run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 186 DBIx::Class::Storage::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 867 DBIx::Class::Storage::DBI::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 654 DBIx::Class::Schema::txn_do() called at t/20-dbic.t line 60 Test::Exception::throws_ok() called at t/20-dbic.t line 61 I got called with DBIx::Error::GeneralError=HASH(0x36aca60) at /home/rabbit/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1/lib/DBIx/Error.pm line 309. DBIx::Error::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1087 eval {...} called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1108 DBIx::Class::Schema::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 112 DBIx::Class::Storage::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 177 DBIx::Class::Storage::BlockRunner::__ANON__() called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Context/Preserve.pm line 27 Context::Preserve::preserve_context() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 206 DBIx::Class::Storage::BlockRunner::_run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 105 DBIx::Class::Storage::BlockRunner::run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 186 DBIx::Class::Storage::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 867 DBIx::Class::Storage::DBI::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 654 DBIx::Class::Schema::txn_do() called at t/20-dbic.t line 60 Test::Exception::throws_ok() called at t/20-dbic.t line 61 I got called with TestError=HASH(0x37847d8) at /home/rabbit/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1/lib/DBIx/Error.pm line 309. DBIx::Error::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1087 eval {...} called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1108 DBIx::Class::Schema::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 112 DBIx::Class::Storage::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 177 DBIx::Class::Storage::BlockRunner::__ANON__() called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Context/Preserve.pm line 27 Context::Preserve::preserve_context() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 206 DBIx::Class::Storage::BlockRunner::_run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 105 DBIx::Class::Storage::BlockRunner::run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 186 DBIx::Class::Storage::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 867 DBIx::Class::Storage::DBI::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 654 DBIx::Class::Schema::txn_do() called at t/20-dbic.t line 69 Test::Exception::throws_ok() called at t/20-dbic.t line 70 t/20-dbic.t .. ok All tests successful. Files=1, Tests=6, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.56 cusr 0.04 csys = 0.62 CPU) Result: PASS
Subject: dbix_error_20dbic.t_with_ddcc02d1.txt
rabbit@Ahasver:~/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1$ prove -I/home/rabbit/devel/dbic/lib -l t/20-dbic.t t/20-dbic.t .. 1/? I got called with DBIx::Error::UniqueViolation=HASH(0x39e4b80) at /home/rabbit/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1/lib/DBIx/Error.pm line 309. DBIx::Error::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1094 eval {...} called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1115 DBIx::Class::Schema::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 113 DBIx::Class::Storage::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 183 DBIx::Class::Storage::BlockRunner::__ANON__() called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Context/Preserve.pm line 27 Context::Preserve::preserve_context() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 212 DBIx::Class::Storage::BlockRunner::_run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 105 DBIx::Class::Storage::BlockRunner::run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 187 DBIx::Class::Storage::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 871 DBIx::Class::Storage::DBI::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 657 DBIx::Class::Schema::txn_do() called at t/20-dbic.t line 38 Test::Exception::throws_ok() called at t/20-dbic.t line 39 I got called with DBIx::Error::NotNullViolation=HASH(0x39a4418) at /home/rabbit/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1/lib/DBIx/Error.pm line 309. DBIx::Error::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1094 eval {...} called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1115 DBIx::Class::Schema::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 113 DBIx::Class::Storage::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 183 DBIx::Class::Storage::BlockRunner::__ANON__() called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Context/Preserve.pm line 27 Context::Preserve::preserve_context() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 212 DBIx::Class::Storage::BlockRunner::_run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 105 DBIx::Class::Storage::BlockRunner::run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 187 DBIx::Class::Storage::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 871 DBIx::Class::Storage::DBI::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 657 DBIx::Class::Schema::txn_do() called at t/20-dbic.t line 47 Test::Exception::throws_ok() called at t/20-dbic.t line 48 I got called with DBIx::Class::Exception=HASH(0x3a6e150) at /home/rabbit/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1/lib/DBIx/Error.pm line 309. DBIx::Error::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1094 eval {...} called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1115 DBIx::Class::Schema::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 113 DBIx::Class::Storage::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 183 DBIx::Class::Storage::BlockRunner::__ANON__() called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Context/Preserve.pm line 27 Context::Preserve::preserve_context() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 212 DBIx::Class::Storage::BlockRunner::_run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 105 DBIx::Class::Storage::BlockRunner::run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 187 DBIx::Class::Storage::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 871 DBIx::Class::Storage::DBI::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 657 DBIx::Class::Schema::txn_do() called at t/20-dbic.t line 60 Test::Exception::throws_ok() called at t/20-dbic.t line 61 # Failed test 'threw DBIx::Error' # at t/20-dbic.t line 61. # expecting: DBIx::Error # found: DBIx::Class::Exception (DBIx::Class::Storage::DBI::_dbh_execute_for_fetch(): execute_for_fetch() aborted with 'PRIMARY KEY must be unique' at populate slice: # { # id => 1, # name => "You" # } at t/20-dbic.t line 57 # ) I got called with TestError=HASH(0x3a10560) at /home/rabbit/.cpanm/work/1465578850.23395/DBIx-Error-1.0.1/lib/DBIx/Error.pm line 309. DBIx::Error::__ANON__() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1094 eval {...} called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 1115 DBIx::Class::Schema::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 113 DBIx::Class::Storage::throw_exception() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 183 DBIx::Class::Storage::BlockRunner::__ANON__() called at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Context/Preserve.pm line 27 Context::Preserve::preserve_context() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 212 DBIx::Class::Storage::BlockRunner::_run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/BlockRunner.pm line 105 DBIx::Class::Storage::BlockRunner::run() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage.pm line 187 DBIx::Class::Storage::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Storage/DBI.pm line 871 DBIx::Class::Storage::DBI::txn_do() called at /home/rabbit/devel/dbic/lib/DBIx/Class/Schema.pm line 657 DBIx::Class::Schema::txn_do() called at t/20-dbic.t line 69 Test::Exception::throws_ok() called at t/20-dbic.t line 70 # Looks like you failed 1 test of 6. t/20-dbic.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/6 subtests Test Summary Report ------------------- t/20-dbic.t (Wstat: 256 Tests: 6 Failed: 1) Failed test: 5 Non-zero exit status: 1 Files=1, Tests=6, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.57 cusr 0.02 csys = 0.62 CPU) Result: FAIL
Subject: dbix_error_carp_instrumentation.patch
diff --git a/lib/DBIx/Error.pm b/lib/DBIx/Error.pm index f6daa05..4dbed76 100644 --- a/lib/DBIx/Error.pm +++ b/lib/DBIx/Error.pm @@ -297,6 +297,18 @@ sub exception_action { return sub { my $msg = shift; + +my $class_of_msg; +my $desc = (length ref $msg) + ? sprintf( '%s%s(0x%x)', + ( defined( $class_of_msg = Scalar::Util::blessed $msg) ? "$class_of_msg=" : '' ), + Scalar::Util::reftype($msg), + Scalar::Util::refaddr($msg), + ) + : $msg +; +Carp::cluck("\n\n\nI got called with $desc\n "); + # Clear the stored DBI exception my $underlying_exception = $last_dbi_exception; undef $last_dbi_exception;
Download (untitled) / with headers
text/plain 313b
I've been looking into the module as I want to use it for presenting better error messages to the users of our various apps and stumbled over this bug report. As all our apps use a DBIC schema to talk to the database it's important that it works with DBIC. Did you further work on fixing the test failure? Thanks!


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.