Skip to content

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

@Sutaai

Description

@Sutaai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Needs TriageThis has not been labeled or discussed for handling yet.Type: BugUnexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions