Error 401 / Error running sync command: object of type 'NoneType' has no len()
robinm0 opened this issue · comments
Confirmation
- I have read the README.md on the project homepage
- I have checked if identical issue already exists
- I have tried downgrading to find version that can be used as a workaround
The problem
Fillms and Tv programmes are scanned; after ratings are read, fails with:
Updated liked list in 0.0 seconds
ERROR Error during [redacted] account access: (401) unauthorized;
Steps to reproduce the behavior
- Updated to 0.29.2
- ran plextraktsync sync
- Exited with error 401
Error trace / logs
2024-02-25 17:03:08,059 ERROR[PlexTraktSync]:Error during [redacted] account access: (401) unauthorized; https://plex.tv/api/v2/user <?xml version="1.0" encoding="UTF-8"?> <errors> <error code="1001" message="User could not be authenticated" status="401"/> </errors>
2024-02-25 17:03:08,062 ERROR[PlexTraktSync]:object of type 'NoneType' has no len()
Traceback (most recent call last):
File "/Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-packages/plextraktsync/cli.py", line 26, in wrap
cmd(*args, **kwargs)
File "/Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-packages/plextraktsync/commands/sync.py", line 68, in sync
runner.sync(walker=w, dry_run=config.dry_run)
File "/Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-packages/plextraktsync/sync/Sync.py", line 105, in sync
if walker.config.walk_watchlist and self.sync_wl:
^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/functools.py", line 1001, in __get__
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-packages/plextraktsync/sync/Sync.py", line 35, in sync_wl
return self.config.sync_wl and len(self.plex_wl) > 0
^^^^^^^^^^^^^^^^^
File "/Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-packages/plextraktsync/plex/PlexWatchList.py", line 21, in __len__
return len(self.watchlist)
^^^^^^^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()
Expected behavior
Normal end of run.
Inspect of problematic items
No response
Workarounds
No response
Install method
pipx
Config file contents
cache:
path: /Users/plex/Library/Caches/PlexTraktSync/trakt_cache
excluded-libraries:
- Private
- Family Holidays
config:
dotenv_override: true
plex:
timeout: 30
logging:
append: true
console_time: false
debug: false
filename: plextraktsync.log
filter_loggers: null
filter: null
sync:
rating_priority: plex
plex_to_trakt:
collection: true
clear_collected: false
ratings: true
watched_status: true
watchlist: true
trakt_to_plex:
liked_lists: true
ratings: true
watched_status: true
watchlist: true
watchlist_as_playlist: false
watch:
add_collection: false
remove_collection: false
scrobble_threshold: 80
username_filter: true
media_progressbar: true
xbmc-providers:
movies: imdb
shows: tvdb
Version
0.29.2
Python Version
3.11.3
Plex Server Version
1.40.0.7998
Operating System and Version
macOS-14.3.1
Problem appears related to 'watchlist' option:
[redacted] ~ % plextraktsync sync --sync=watchlist
INFO PlexTraktSync [0.29.2]
INFO Connecting with url:
https://192-168-1-[redacted], timeout 30 seconds
WARNING Partial walk, disabling liked lists updating. Liked lists won't update
because it needs full library sync.
INFO Preload shows data
INFO Preloaded shows data (0 shows)
WARNING Running partial library sync. Liked lists won't update because it needs
full library sync.
ERROR Error during [redacted] account access: (401) unauthorized;
https://plex.tv/api/v2/user <?xml version="1.0" encoding="UTF-8"?>
<errors> <error code="1001" message="User could not be authenticated"
status="401"/> </errors>
ERROR object of type 'NoneType' has no len()
╭───────────────── Traceback (most recent call last)
─────────────────╮
│ /Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-pac │
│ kages/plextraktsync/cli.py:26 in wrap │
│ │
│ 23 │ │ │ cmd = getattr(module, name) │
│ 24 │ │ │ │
│ 25 │ │ │ try: │
│ ❱ 26 │ │ │ │ cmd(*args, **kwargs) │
│ 27 │ │ │ except EOFError as e: │
│ 28 │ │ │ │ raise ClickException(f"Program requested term │
│ connected: {e}") │
│ 29 │ │ │ except ClickException as e: │
│ │
│ /Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-pac │
│ kages/plextraktsync/commands/sync.py:68 in sync │
│ │
│ 65 │ │ │ w.print_plan(print=logger.info) │
│ 66 │ │ if dry_run: │
│ 67 │ │ │ logger.info("Enabled dry-run mode: not making actu │
│ ❱ 68 │ │ runner.sync(walker=w, dry_run=config.dry_run) │
│ 69 │
│ │
│ /Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-pac │
│ kages/plextraktsync/sync/Sync.py:105 in sync │
│ │
│ 102 │ │ │ │ │ with measure_time("Updated liked list"): │
│ 103 │ │ │ │ │ │ trakt_lists.sync() │
│ 104 │ │ │
│ ❱ 105 │ │ if walker.config.walk_watchlist and self.sync_wl: │
│ 106 │ │ │ with measure_time("Updated watchlist"): │
│ 107 │ │ │ │ self.sync_watchlist(walker, dry_run=dry_run) │
│ 108 │
│ │
│ /opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework │
│ /Versions/3.11/lib/python3.11/functools.py:1001 in get │
│ │
│ 998 │ │ │ │ # check if another thread filled cache while │
│ 999 │ │ │ │ val = cache.get(self.attrname, _NOT_FOUND) │
│ 1000 │ │ │ │ if val is _NOT_FOUND: │
│ ❱ 1001 │ │ │ │ │ val = self.func(instance) │
│ 1002 │ │ │ │ │ try: │
│ 1003 │ │ │ │ │ │ cache[self.attrname] = val │
│ 1004 │ │ │ │ │ except TypeError: │
│ │
│ /Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-pac │
│ kages/plextraktsync/sync/Sync.py:35 in sync_wl │
│ │
│ 32 │ │
│ 33 │ @cached_property │
│ 34 │ def sync_wl(self): │
│ ❱ 35 │ │ return self.config.sync_wl and len(self.plex_wl) > 0 │
│ 36 │ │
│ 37 │ @cached_property │
│ 38 │ def trakt_wl(self): │
│ │
│ /Users/plex/.local/pipx/venvs/plextraktsync/lib/python3.11/site-pac │
│ kages/plextraktsync/plex/PlexWatchList.py:21 in len │
│ │
│ 18 │ │ return iter(self.watchlist) │
│ 19 │ │
│ 20 │ def len(self): │
│ ❱ 21 │ │ return len(self.watchlist) │
│ 22 │ │
│ 23 │ def contains(self, m: Media): │
│ 24 │ │ return m.plex.item.guid in self.guidmap │
╰─────────────────────────────────────────────────────────────────────╯
TypeError: object of type 'NoneType' has no len()
Error: Error running sync command: object of type 'NoneType' has no len()
Options 'movies' and 'shows' end normally.
edit your post and put terminal output to code blocks
Seems same error reported here:
no info whether this appeared with upgrade (did you try downgrading) or is this new install? have you changed your config recently?
from trace I guess you are using managed account?
The problem has appeared after upgrade to 0.29.2 from 0.28.12. Last run under that version ended without error. I have not tried downgrading. 'plextraktsync sync' is run from a cron job, with other commands, such as self-update, run manually as and when.
Config has not changed since the installation last year.
Not sure what you mean by managed account. Plex, with Plex Pass, is running on an M1 Mac Mini, on which I also have Handbrake installed. Storage is on 2 Synology diskstations, totalling 14TB, with about 5.7TB currently free.
I have (hopefully) edited my previous post as suggested.
you need to test downgrade to see if it's code error or something at trakt.tv side has changed. i.e does the old downgraded version still work? try to pin point exact version what caused breakage if that's the case.
and managed account:
this still needs edit (scroll to see your whole post):
you may try this pr:
but in short, seems your plex account token is missing or expired or whatever reason plex.tv is rejecting it:
PlexTraktSync/plextraktsync/plex/PlexApi.py
Lines 186 to 188 in bdd8804
plex-login subcommand may help.
syncing watchlist requires plex account oken, if you can't have it, you can turn off and sync to playlist instead
# If you prefer to fetch trakt watchlist as a playlist instead of
# plex watchlist, toggle this to true (is read only if watchlist=true)
watchlist_as_playlist: true
Right, now I see that 'managed' account refers to Plex. Thank you.
I have got it running to completion, but it took several attempts using the 'plex-login' option. Initially, all attempts to log-in using the pwd (which hadn't been changed) failed, with either the Plex username or Plex account e-mail address. Eventually, after changing the pwd for the username (me), and some https errors (apparently expected), it connected and wrote details to a .yml file..
I see that you are implementing a friendlier error message for this problem.
Thanks again for your help.