[V3 Downloader] Missing repos from repo list #1950

Closed
opened 2018-07-20 20:22:45 +02:00 by aikaterna · 3 comments
aikaterna commented 2018-07-20 20:22:45 +02:00 (Migrated from github.com)

Command bugs

Command name

[p]repo list

What cog is this command from?

Downloader

What were you expecting to happen?

For Red to reliably show installed repos every time.

What actually happened?

Some users are reporting that they have installed repos and after this issue occurs, using [p]repo list will return a blank list with just the "Installed Repos:" header. Going into the RepoManager folder in the bot's data path shows all of the previously-installed repo folders. This is not a holdover issue from the downloader changes in roughly beta 13 as this can occur with new instances. The cause is a corrupted info.json and the subsequent UnicodeDecodeError that stops RepoManager._load_repos() from executing on startup. However, I'm not sure how these info.json files change encoding type over time. Opening the info.json from the affected repo folder did not show any obvious file changes plain text-wise (looked at it with nano).

How can we reproduce this issue?

Unfortunately, even with asking users specific questions in support and even having this issue occur on one of my own bots I am unable to find why this happens. Attached is the traceback from the affected bot on startup:

Task exception was never retrieved
future: <Task finished coro=<RepoManager._load_repos() done, defined at /home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py:618> exception=UnicodeDecodeError('utf-8', b"\x01D\xc79\x12b\x9e\xd6\xa4\xb8\x13\x93TDR \xe3w\xd3@\xc4H$H=2\x0e48\xac\xa6V\xb2\xb3\x19\x1cu\xe9\xed\xae'\xac\xb2\xe7!j\xc7^\xb1\xca\xe2\xa6\xd8\xa8\x9e\xd8\xad\x95\xe6\xa7v)\x9a\x81\xef\xdc\xa2h\x9c~\xba&\xc6G\x1d\x1c\x80\xc3\x10\xd7\xda\x96\xc7\x885$\xc0,\xb3\x12\x18\x89\xec\xb5\xa9e\x8ax1\x91\xc7\\\xa2\x04\x879\x14\xc3\x8a\xcaek*\xda\x9d\xda&\xc6G\x1dL\x01\x92\xc6G\x1dr\x89\xa2r:$z", 2, 3, 'invalid continuation byte')>
Traceback (most recent call last):
  File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 621, in _load_repos
    ret[folder.stem] = await Repo.from_folder(folder)
  File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 487, in from_folder
    repo._update_available_modules()
  File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 153, in _update_available_modules
    curr_modules.append(Installable(location=self.folder_path / name))
  File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 68, in __init__
    super().__init__(location)
  File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 18, in __init__
    self._read_info_file()
  File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 125, in _read_info_file
    super()._read_info_file()
  File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 28, in _read_info_file
    info = json.load(f)
  File "/usr/lib/python3.6/json/__init__.py", line 296, in load
    return loads(fp.read(),
  File "/home/aikaterna/v3/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 2: invalid continuation byte
# Command bugs #### Command name [p]repo list #### What cog is this command from? Downloader #### What were you expecting to happen? For Red to reliably show installed repos every time. #### What actually happened? Some users are reporting that they have installed repos and after this issue occurs, using [p]repo list will return a blank list with just the "Installed Repos:" header. Going into the RepoManager folder in the bot's data path shows all of the previously-installed repo folders. This is not a holdover issue from the downloader changes in roughly beta 13 as this can occur with new instances. The cause is a corrupted info.json and the subsequent UnicodeDecodeError that stops RepoManager._load_repos() from executing on startup. However, I'm not sure how these info.json files change encoding type over time. Opening the info.json from the affected repo folder did not show any obvious file changes plain text-wise (looked at it with nano). #### How can we reproduce this issue? Unfortunately, even with asking users specific questions in support and even having this issue occur on one of my own bots I am unable to find why this happens. Attached is the traceback from the affected bot on startup: ``` Task exception was never retrieved future: <Task finished coro=<RepoManager._load_repos() done, defined at /home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py:618> exception=UnicodeDecodeError('utf-8', b"\x01D\xc79\x12b\x9e\xd6\xa4\xb8\x13\x93TDR \xe3w\xd3@\xc4H$H=2\x0e48\xac\xa6V\xb2\xb3\x19\x1cu\xe9\xed\xae'\xac\xb2\xe7!j\xc7^\xb1\xca\xe2\xa6\xd8\xa8\x9e\xd8\xad\x95\xe6\xa7v)\x9a\x81\xef\xdc\xa2h\x9c~\xba&\xc6G\x1d\x1c\x80\xc3\x10\xd7\xda\x96\xc7\x885$\xc0,\xb3\x12\x18\x89\xec\xb5\xa9e\x8ax1\x91\xc7\\\xa2\x04\x879\x14\xc3\x8a\xcaek*\xda\x9d\xda&\xc6G\x1dL\x01\x92\xc6G\x1dr\x89\xa2r:$z", 2, 3, 'invalid continuation byte')> Traceback (most recent call last): File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 621, in _load_repos ret[folder.stem] = await Repo.from_folder(folder) File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 487, in from_folder repo._update_available_modules() File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 153, in _update_available_modules curr_modules.append(Installable(location=self.folder_path / name)) File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 68, in __init__ super().__init__(location) File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 18, in __init__ self._read_info_file() File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 125, in _read_info_file super()._read_info_file() File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 28, in _read_info_file info = json.load(f) File "/usr/lib/python3.6/json/__init__.py", line 296, in load return loads(fp.read(), File "/home/aikaterna/v3/lib/python3.6/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 2: invalid continuation byte ```
Tobotimus commented 2018-09-11 04:10:51 +02:00 (Migrated from github.com)

I'm gonna self-assign this as it's an issue I'm somehow able to reproduce, although I'm not entirely sure of the conditions. I'll investigate.

I'm gonna self-assign this as it's an issue I'm somehow able to reproduce, although I'm not entirely sure of the conditions. I'll investigate.
Tobotimus commented 2018-09-11 04:20:02 +02:00 (Migrated from github.com)

OK, here's what I've found:

  • I previously tried to add a repo, but doing so failed since the repo was private.
  • This created a new sub-directory in RepoManager's repos directory, but it did not create an entry in RepoManager's settings.json. The sub-directory was also empty (not a git repository)
  • This created this traceback on the loading of RepoManager:
Task exception was never retrieved
future: <Task finished coro=<RepoManager._load_repos() done, defined at /home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/downloader/repo_manager.py:618> exception=MissingGitRepo('A git repo does not exist at path: /home/tobyh/Red-DiscordBot/case.data/cogs/RepoManager/repos/Tobo-PrivateCogs')>
Traceback (most recent call last):
  File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/downloader/repo_manager.py", line 625, in _load_repos
    ret[folder.stem] = await Repo.from_folder(folder)
  File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/downloader/repo_manager.py", line 485, in from_folder
    repo.branch = await repo.current_branch()
  File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/downloader/repo_manager.py", line 213, in current_branch
    raise MissingGitRepo("A git repo does not exist at path: {}".format(self.folder_path))
redbot.cogs.downloader.errors.MissingGitRepo: A git repo does not exist at path: /home/tobyh/Red-DiscordBot/case.data/cogs/RepoManager/repos/Tobo-PrivateCogs

I think it's likely _load_repos is exiting early at the first sight of an exception. This should not be occurring and instead it should only fail on the repo causing the exception, and continue to load all other repos. We can also look at preventing these types of exceptions, since obviously the one described above is another bug.

OK, here's what I've found: - I previously tried to add a repo, but doing so failed since the repo was private. - This created a new sub-directory in RepoManager's `repos` directory, but it did not create an entry in RepoManager's settings.json. The sub-directory was also empty (not a git repository) - This created this traceback on the loading of RepoManager: ```py Task exception was never retrieved future: <Task finished coro=<RepoManager._load_repos() done, defined at /home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/downloader/repo_manager.py:618> exception=MissingGitRepo('A git repo does not exist at path: /home/tobyh/Red-DiscordBot/case.data/cogs/RepoManager/repos/Tobo-PrivateCogs')> Traceback (most recent call last): File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/downloader/repo_manager.py", line 625, in _load_repos ret[folder.stem] = await Repo.from_folder(folder) File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/downloader/repo_manager.py", line 485, in from_folder repo.branch = await repo.current_branch() File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/downloader/repo_manager.py", line 213, in current_branch raise MissingGitRepo("A git repo does not exist at path: {}".format(self.folder_path)) redbot.cogs.downloader.errors.MissingGitRepo: A git repo does not exist at path: /home/tobyh/Red-DiscordBot/case.data/cogs/RepoManager/repos/Tobo-PrivateCogs ``` I think it's likely `_load_repos` is exiting early at the first sight of an exception. This should not be occurring and instead it should only fail on the repo causing the exception, and continue to load all other repos. We can also look at preventing these types of exceptions, since obviously the one described above is another bug.
Tobotimus commented 2018-09-24 02:36:44 +02:00 (Migrated from github.com)

Resolved by #2121.

Resolved by #2121.
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#1950
No description provided.