Starting a bot with missing configuration may exit with code 1 instead of expected 78 #6572

Closed
opened 2025-05-07 11:10:53 +02:00 by Sutaai · 3 comments
Sutaai commented 2025-05-07 11:10:53 +02:00 (Migrated from github.com)

What Red version are you using?

3.5.20 and earlier

What were you trying to do?

Attempting to launch the bot using the flag --no-prompt, with no token and/or prefix set up beforehand.

What did you expect to happen?

Process to exit with code 78 for configuration error as expected in the following lines:
https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/redbot/core/_cli.py#L26
https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/redbot/core/data_manager.py#L116-L121

What actually happened?

The process will exit with error code 1 due to the following traceback:

Traceback (most recent call last):
  File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 521, in main
    loop.run_forever()
  File "uvloop/loop.pyx", line 1379, in uvloop.loop.Loop.run_forever
  File "uvloop/loop.pyx", line 557, in uvloop.loop.Loop._run
  File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 470, in red_exception_handler
    red_task.result()
  File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 363, in run_bot
    sys.exit(ExitCodes.CONFIGURATION_ERROR)
SystemExit: 78

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 563, in <module>
    main()
  File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 539, in main
    loop.run_until_complete(shutdown_handler(red, None, exc.code))
  File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
  File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 441, in shutdown_handler
    await red.close()
  File "/data/.venv/lib/python3.11/site-packages/redbot/core/bot.py", line 2278, in close
    await super().close()
  File "/data/.venv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 247, in close
    await super().close()  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^
  File "/data/.venv/lib/python3.11/site-packages/discord/shard.py", line 554, in close
    await self._closing_task
  File "/data/.venv/lib/python3.11/site-packages/discord/shard.py", line 551, in _close
    self.__queue.put_nowait(EventItem(EventType.clean_close, None, None))
    ^^^^^^^^^^^^
AttributeError: 'Red' object has no attribute '_AutoShardedClient__queue'. Did you mean: '_AutoShardedClient__shards'?

How can we reproduce this error?

  1. Install Red.
  2. Configure an instance as you'd normally expect.
  3. Attempt to launch the bot with --no-prompt without filling in token/prefix.
  4. Check error code with echo $?.

Anything else?

This process has been realized on Ubuntu.

Some conversation about the topic has emerged in #coding of the Discord server. See https://discord.com/channels/133049272517001216/160386989819035648/1369259135018733619

### What Red version are you using? 3.5.20 and earlier ### What were you trying to do? Attempting to launch the bot using the flag `--no-prompt`, with no token and/or prefix set up beforehand. ### What did you expect to happen? Process to exit with code 78 for configuration error as expected in the following lines: https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/redbot/core/_cli.py#L26 https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/redbot/core/data_manager.py#L116-L121 ### What actually happened? The process will exit with error code 1 due to the following traceback: ```py Traceback (most recent call last): File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 521, in main loop.run_forever() File "uvloop/loop.pyx", line 1379, in uvloop.loop.Loop.run_forever File "uvloop/loop.pyx", line 557, in uvloop.loop.Loop._run File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 470, in red_exception_handler red_task.result() File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 363, in run_bot sys.exit(ExitCodes.CONFIGURATION_ERROR) SystemExit: 78 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 563, in <module> main() File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 539, in main loop.run_until_complete(shutdown_handler(red, None, exc.code)) File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete File "/data/.venv/lib/python3.11/site-packages/redbot/__main__.py", line 441, in shutdown_handler await red.close() File "/data/.venv/lib/python3.11/site-packages/redbot/core/bot.py", line 2278, in close await super().close() File "/data/.venv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 247, in close await super().close() # type: ignore ^^^^^^^^^^^^^^^^^^^^^ File "/data/.venv/lib/python3.11/site-packages/discord/shard.py", line 554, in close await self._closing_task File "/data/.venv/lib/python3.11/site-packages/discord/shard.py", line 551, in _close self.__queue.put_nowait(EventItem(EventType.clean_close, None, None)) ^^^^^^^^^^^^ AttributeError: 'Red' object has no attribute '_AutoShardedClient__queue'. Did you mean: '_AutoShardedClient__shards'? ``` ### How can we reproduce this error? 1. Install Red. 2. Configure an instance as you'd normally expect. 3. Attempt to launch the bot with `--no-prompt` without filling in token/prefix. 4. Check error code with `echo $?`. ### Anything else? This process has been realized on Ubuntu. Some conversation about the topic has emerged in #coding of the Discord server. See https://discord.com/channels/133049272517001216/160386989819035648/1369259135018733619
Flame442 commented 2025-11-20 14:48:04 +01:00 (Migrated from github.com)

This issue appears to also happen when using the --dry-run flag
https://discord.com/channels/133049272517001216/160386989819035648/1441055734727970983

This issue appears to also happen when using the `--dry-run` flag https://discord.com/channels/133049272517001216/160386989819035648/1441055734727970983
Jackenmen commented 2026-03-04 22:04:55 +01:00 (Migrated from github.com)

Marking as a dependency issue - will close on next d.py bump:
https://github.com/Rapptz/discord.py/pull/10422

Marking as a dependency issue - will close on next d.py bump: https://github.com/Rapptz/discord.py/pull/10422
Owner

Behoben: Red.close() kommt jetzt mit einem Bot klar, der nie verbunden war (der AttributeError _AutoShardedClient__queue wird abgefangen). redbot <instance> --no-prompt ohne Token und Prefix beendet sich jetzt mit Exit-Code 78. Getestet mit redbot --no-instance --no-prompt.


Generated by Claude Code

Behoben: `Red.close()` kommt jetzt mit einem Bot klar, der nie verbunden war (der AttributeError `_AutoShardedClient__queue` wird abgefangen). `redbot <instance> --no-prompt` ohne Token und Prefix beendet sich jetzt mit Exit-Code 78. Getestet mit `redbot --no-instance --no-prompt`. --- _Generated by [Claude Code](https://claude.ai/code)_
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
2 participants
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#6572
No description provided.