Bug 6337 - descending into some genres results in a failed query
: descending into some genres results in a failed query
Status: RESOLVED WORKSFORME
Product: SB Controller
Classification: Unclassified
Component: Browser
: unspecified
: Macintosh Other
: -- normal with 1 vote (vote)
: Future
Assigned To: Ben Klaas
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-12-12 11:11 UTC by Ben Klaas
Modified: 2011-01-13 08:31 UTC (History)
0 users

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Klaas 2007-12-12 11:11:18 UTC
jive side:

130842:16260 WARN (Comet.lua:668) - Comet:request error: request failed with error: Bad dispatch!
130842:16260 ERROR (SlimBrowserApplet.lua:653) - request failed with error: Bad dispatch!

SC side:
[13:07:55.3123] Slim::Control::Request::execute (1719) Error: While trying to run function coderef [Slim::Control::Queries::artistsQuery]: [Can't call method "id" on an undefined value at /Users/bklaas/svk/slim/branches/mainMenuRework/Slim/Control/Queries.pm line 569.


problem is in $obj->id() call in this chunk of Slim::Control::Queries

                for my $obj (@data[$start..$end]) {

                        my $id = $obj->id();
                        $id += 0;

                        if ($menuMode){
                                $request->addResultLoop($loopname, $cnt, 'text', $obj->name);
                                my $params = {
                                        'artist_id' => $id,
                                };
                                $request->addResultLoop($loopname, $cnt, 'params', $params);
                        }
                        else {
                                $request->addResultLoop($loopname, $cnt, 'id', $id);
                                $request->addResultLoop($loopname, $cnt, 'artist', $obj->name);
                        }

                        $cnt++;
                }
Comment 1 KDF 2007-12-12 11:37:47 UTC
Thats the trigger, but the cause comes from @data.   Which genres? 

Can you add:

use Data::Dump;
Data::Dump::dump($obj) 

before the obj->id call?

something from the resultset or the va object is the real problem.

brute force, add:

next if !$obj->can('id')

before the obj->id call
Comment 2 Ben Klaas 2007-12-13 13:04:28 UTC
this is a failed query to genre "Classic Rock":

[15:02:49.0508] Data::Dump::dump (100) Warning: do {
  my $a = bless({
    _column_data  => {
                       id => 134,
                       musicbrainz_id => undef,
                       musicmagic_mixable => undef,
                       name => "Simply red",
                       namesearch => "SIMPLY RED",
                       namesort => "SIMPLY RED",
                     },
    _in_storage   => 1,
    result_source => bless({
                       _columns => {
                             id => {},
                             musicbrainz_id => {},
                             musicmagic_mixable => {},
                             name => {},
                             namesearch => {},
                             namesort => {},
                           },
                       _columns_info_loaded => 0,
                       _ordered_columns => [
                             "id",
                             "name",
                             "namesort",
                             "musicmagic_mixable",
                             "namesearch",
                             "musicbrainz_id",
                           ],
                       _primaries => ["id"],
                       _relationships => {
                             contributorAlbums => {
                                                    attrs  => {
                                                                accessor       => "multi",
                                                                cascade_copy   => 1,
                                                                cascade_delete => 1,
                                                                join_type      => "LEFT",
                                                              },
                                                    class  => "Slim::Schema::ContributorAlbum",
                                                    cond   => { "foreign.contributor" => "self.id" },
                                                    source => "Slim::Schema::ContributorAlbum",
                                                  },
                             contributorTracks => {
                                                    attrs  => {
                                                                accessor       => "multi",
                                                                cascade_copy   => 1,
                                                                cascade_delete => 1,
                                                                join_type      => "LEFT",
                                                              },
                                                    class  => "Slim::Schema::ContributorTrack",
                                                    cond   => { "foreign.contributor" => "self.id" },
                                                    source => "Slim::Schema::ContributorTrack",
                                                  },
                           },
                       _resultset => undef,
                       _unique_constraints => { namesearch => ["namesearch"], primary => 'fix' },
                       name => "contributors",
                       result_class => "Slim::Schema::Contributor",
                       resultset_attributes => { alias => "me" },
                       resultset_class => "Slim::Schema::ResultSet::Contributor",
                       schema => "Slim::Schema",
                       source_name => "Contributor",
                     }, "DBIx::Class::ResultSource::Table"),
  }, "Slim::Schema::Contributor");
  $a->{result_source}{_unique_constraints}{primary} = $a->{result_source}{_primaries};
  $a;
}
[15:02:49.0584] Data::Dump::dump (100) Warning: undef
[15:02:49.0588] Slim::Control::Request::execute (1719) Error: While trying to run function coderef [Slim::Control::Queries::artistsQuery]: [Can't call method "id" on an undefined value at /Users/bklaas/svk/slim/branches/mainMenuRework/Slim/Control/Queries.pm line 571.



this is a successful query to genre "Ambient":
[15:03:19.5845] Data::Dump::dump (100) Warning: do {
  my $a = bless({
    _column_data  => {
                       id => 178,
                       musicbrainz_id => undef,
                       musicmagic_mixable => undef,
                       name => "Brian Eno",
                       namesearch => "BRIAN ENO",
                       namesort => "BRIAN ENO",
                     },
    _in_storage   => 1,
    result_source => bless({
                       _columns => {
                             id => {},
                             musicbrainz_id => {},
                             musicmagic_mixable => {},
                             name => {},
                             namesearch => {},
                             namesort => {},
                           },
                       _columns_info_loaded => 0,
                       _ordered_columns => [
                             "id",
                             "name",
                             "namesort",
                             "musicmagic_mixable",
                             "namesearch",
                             "musicbrainz_id",
                           ],
                       _primaries => ["id"],
                       _relationships => {
                             contributorAlbums => {
                                                    attrs  => {
                                                                accessor       => "multi",
                                                                cascade_copy   => 1,
                                                                cascade_delete => 1,
                                                                join_type      => "LEFT",
                                                              },
                                                    class  => "Slim::Schema::ContributorAlbum",
                                                    cond   => { "foreign.contributor" => "self.id" },
                                                    source => "Slim::Schema::ContributorAlbum",
                                                  },
                             contributorTracks => {
                                                    attrs  => {
                                                                accessor       => "multi",
                                                                cascade_copy   => 1,
                                                                cascade_delete => 1,
                                                                join_type      => "LEFT",
                                                              },
                                                    class  => "Slim::Schema::ContributorTrack",
                                                    cond   => { "foreign.contributor" => "self.id" },
                                                    source => "Slim::Schema::ContributorTrack",
                                                  },
                           },
                       _resultset => undef,
                       _unique_constraints => { namesearch => ["namesearch"], primary => 'fix' },
                       name => "contributors",
                       result_class => "Slim::Schema::Contributor",
                       resultset_attributes => { alias => "me" },
                       resultset_class => "Slim::Schema::ResultSet::Contributor",
                       schema => "Slim::Schema",
                       source_name => "Contributor",
                     }, "DBIx::Class::ResultSource::Table"),
  }, "Slim::Schema::Contributor");
  $a->{result_source}{_unique_constraints}{primary} = $a->{result_source}{_primaries};
  $a;
}
[15:03:19.5911] Data::Dump::dump (100) Warning: do {
  my $a = bless({
    _column_data  => {
                       id => 224,
                       musicbrainz_id => undef,
                       musicmagic_mixable => undef,
                       name => "Frou Frou",
                       namesearch => "FROU FROU",
                       namesort => "FROU FROU",
                     },
    _in_storage   => 1,
    result_source => bless({
                       _columns => {
                             id => {},
                             musicbrainz_id => {},
                             musicmagic_mixable => {},
                             name => {},
                             namesearch => {},
                             namesort => {},
                           },
                       _columns_info_loaded => 0,
                       _ordered_columns => [
                             "id",
                             "name",
                             "namesort",
                             "musicmagic_mixable",
                             "namesearch",
                             "musicbrainz_id",
                           ],
                       _primaries => ["id"],
                       _relationships => {
                             contributorAlbums => {
                                                    attrs  => {
                                                                accessor       => "multi",
                                                                cascade_copy   => 1,
                                                                cascade_delete => 1,
                                                                join_type      => "LEFT",
                                                              },
                                                    class  => "Slim::Schema::ContributorAlbum",
                                                    cond   => { "foreign.contributor" => "self.id" },
                                                    source => "Slim::Schema::ContributorAlbum",
                                                  },
                             contributorTracks => {
                                                    attrs  => {
                                                                accessor       => "multi",
                                                                cascade_copy   => 1,
                                                                cascade_delete => 1,
                                                                join_type      => "LEFT",
                                                              },
                                                    class  => "Slim::Schema::ContributorTrack",
                                                    cond   => { "foreign.contributor" => "self.id" },
                                                    source => "Slim::Schema::ContributorTrack",
                                                  },
                           },
                       _resultset => undef,
                       _unique_constraints => { namesearch => ["namesearch"], primary => 'fix' },
                       name => "contributors",
                       result_class => "Slim::Schema::Contributor",
                       resultset_attributes => { alias => "me" },
                       resultset_class => "Slim::Schema::ResultSet::Contributor",
                       schema => "Slim::Schema",
                       source_name => "Contributor",
                     }, "DBIx::Class::ResultSource::Table"),
  }, "Slim::Schema::Contributor");
  $a->{result_source}{_unique_constraints}{primary} = $a->{result_source}{_primaries};
  $a;
}
Comment 3 KDF 2007-12-13 15:36:51 UTC
ok, well, that makes is clear that were getting an empty $obj in @data.  the va object is unshifted, so if it were a bad va object, I would have expected it to be the first item.  This is the second, which leads us back to line 465 where $rs is defined.

I thing sql debugging should show the query being sent for that search, then it's a matter of finding out why the element of the db is coming back with a non-object.  

I think for the near term, we can use:

next if !$obj;

This will avoid a crash for data causing this case.
Comment 4 Ben Klaas 2007-12-14 07:31:25 UTC
change 15296 has the workaround


KDF-- appreciate the debugging here. I'm pretty sure I've got a section of my music library that has some lousy ID3 tagging. I normally don't browse to this section of the library, but in a genre search these problematic files would tend to come up more.

Bad tags aside, this isn't great behavior...I'm happy with the workaround, but this bug should stay open in lieu of understanding why empty $obj are being returned.
Comment 5 KDF 2007-12-14 08:34:18 UTC
I totally agree.  noartist/nogenre/noalbum should be taking care of this so we eventually need to find the cause. the data objects are always a hard one for me to interpret and it's rabbit warren when you try to trace them back.
Comment 6 Ben Klaas 2007-12-26 09:18:33 UTC
This won't be looked at pre-7.0
Comment 7 Richard Titmuss 2008-03-12 04:53:35 UTC
Reset priority
Comment 8 Ben Klaas 2011-01-13 08:31:02 UTC
closing this due to neglect. I think if it were still an important problem we'd be hearing about it. My Music->Genres->Classic Rock works for me now