Cog-Creators / Cog-Creators/Red-DiscordBot

[Downloader] Deleting a repo during `[p]cog update` causes an error

Open
#4,057 0 comments 0 reactions 1 assignee Claimed by @Jackenmen View on GitHub
Category: Cogs - Downloader Status: In Progress Type: Bug
Dominant language
Python
Stars
5.7k
Forks
2.5k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

# Command bugs

#### Command name

`cog update` (and kinda `repo delete`)

#### What cog is this command from?

Downloader

#### What were you expecting to happen?

The cog update to continue updating and skip the repo it expected to be there but wasn't.

#### What actually happened?

I got a traceback without a message showing cogs had been updated, and running `cog update` again revealed that not all cogs had been updated. I suspect some cogs were updated.

Traceback:

```
Exception in command 'cog update'
Traceback (most recent call last):
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\redbot\cogs\downloader\downloader.py", line 929, in _cog_update
await self._cog_update_logic(ctx, cogs=cogs)
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\redbot\cogs\downloader\downloader.py", line 1001, in _cog_update_logic
cogs_to_check, check_failed = await self._get_cogs_to_check(repos=repos, cogs=cogs)
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\redbot\cogs\downloader\downloader.py", line 1247, in _get_cogs_to_check
__, failed = await self._repo_manager.update_repos()
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\redbot\cogs\downloader\repo_manager.py", line 1167, in update_repos
updated_repo, (old, new) = await self.update_repo(repo.name)
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\redbot\cogs\downloader\repo_manager.py", line 1133, in update_repo
repo = self._repos[repo_name]
KeyError: 'rjmtest'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\redbot\core\commands\commands.py", line 799, in invoke
await super().invoke(ctx)
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\discord\ext\commands\core.py", line 1234, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Data\Red\BotVenv-3.8.2\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'rjmtest'
```

#### How can we reproduce this issue?

1. Add a new repo you are willing to remove later on
1a. `repo add temptest https://github.com/Vexed01/vexed-unsupported-cogs`
2. Run `cog update`
3. During `cog update`, delete a repo
3a. `repo delete temptest`
4. Wait for it to error

#### Other details
My reproduction: https://ptb.discordapp.com/channels/133049272517001216/133251234164375552/730685033077145670

This is a naturally stupid thing to do. But then users are stupid.

_The "issue" as such here isn't necessarily the traceback, the "issue" is that it errors and stops halfway through updating._

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.