Skip to content

"Invalid library sectionID: None" after PlexPartialObject.reload() #1380

@krin-san

Description

@krin-san

Describe the Bug

For some reason explicitly calling reload() on PlexPartialObject causes this object to lose librarySectionID value which causes any data editing attempts to fail with exception "Invalid library sectionID: None".

I have tried to compare Music Album genres for all albums to a local list, but .search() was loading only 2 genres for each album. To get the full list of genres, album has to be reloaded but after reloading it is not editable.

Code Snippets

album = plex.library.section('Music').searchAlbums(limit=1, filters=...)[0]
print(album.section()) // <MusicSection:x:Music>
album.reload()
print(album.section()) // NotFound: Invalid library sectionID: None

Expected Behavior

Reloading an object shouldn't cause it to lose the connection to the library section it was found in and should remain editable.

Additional Context

Example stack trace:

File /opt/conda/lib/python3.11/site-packages/plexapi/base.py:647, in PlexPartialObject.saveEdits(self)
    645 edits = self._edits
    646 self._edits = None
--> 647 self._edit(**edits)
    648 return self

File /opt/conda/lib/python3.11/site-packages/plexapi/base.py:586, in PlexPartialObject._edit(self, **kwargs)
    583 if 'type' not in kwargs:
    584     kwargs['type'] = utils.searchType(self._searchType)
--> 586 self.section()._edit(items=self, **kwargs)
    587 return self

File /opt/conda/lib/python3.11/site-packages/plexapi/base.py:670, in PlexPartialObject.section(self)
    668 def section(self):
    669     """ Returns the :class:`~plexapi.library.LibrarySection` this item belongs to. """
--> 670     return self._server.library.sectionByID(self.librarySectionID)

File /opt/conda/lib/python3.11/site-packages/plexapi/library.py:111, in Library.sectionByID(self, sectionID)
    109     return self._sectionsByID[sectionID]
    110 except KeyError:
--> 111     raise NotFound(f'Invalid library sectionID: {sectionID}') from None

NotFound: Invalid library sectionID: None

Operating System and Version

docker.io/jupyter/minimal-notebook@sha256:9aef9e53b7d8bdc7bdd9a2824fe6287081131bc02bf03edc1450ab9413646837

Plex Media Server Version

1.40.0.7998

Python Version

3.11.6

PlexAPI Version

4.15.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions