[Cleanup] Cleanup messages with large int errors #4619

Closed
opened 2020-11-17 19:55:03 +01:00 by aikaterna · 0 comments
aikaterna commented 2020-11-17 19:55:03 +01:00 (Migrated from github.com)

Command bugs

Command name

[p]cleanup messages

What cog is this command from?

Cleanup

What were you expecting to happen?

To have a graceful user friendly exception/message for a very large number or to try to clean that many messages

What actually happened?

Traceback (most recent call last):
  File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/.../cat38/lib/python3.8/site-packages/redbot/cogs/cleanup/cleanup.py", line 417, in messages
    cont = await self.check_100_plus(ctx, number)
  File "/.../cat38/lib/python3.8/site-packages/redbot/cogs/cleanup/cleanup.py", line 55, in check_100_plus
    number=humanize_number(number)
  File "/.../cat38/lib/python3.8/site-packages/redbot/core/utils/chat_formatting.py", line 536, in humanize_number
    return format_decimal(val, locale=get_babel_regional_format(override_locale))
  File "/.../cat38/lib/python3.8/site-packages/babel/numbers.py", line 415, in format_decimal
    return pattern.apply(
  File "/.../cat38/lib/python3.8/site-packages/babel/numbers.py", line 996, in apply
    number = self._quantize_value(value, locale, frac_prec)
  File "/.../cat38/lib/python3.8/site-packages/babel/numbers.py", line 1065, in _quantize_value
    rounded = value.quantize(quantum)
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

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

Traceback (most recent call last):
  File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "/.../cat38/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 825, in invoke
    await super().invoke(ctx)
  File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1329, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/core.py", line 859, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidOperation: [<class 'decimal.InvalidOperation'>]

How can we reproduce this issue?

Seems like a babel issue, but try with a very large number like 999999999999999999999999999999999999999999. I didn't determine where the large number cutoff was. Seems to do just fine with 2^64-1 and values slightly above it too.

# Command bugs #### Command name [p]cleanup messages #### What cog is this command from? Cleanup #### What were you expecting to happen? To have a graceful user friendly exception/message for a very large number or to try to clean that many messages #### What actually happened? ``` Traceback (most recent call last): File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/.../cat38/lib/python3.8/site-packages/redbot/cogs/cleanup/cleanup.py", line 417, in messages cont = await self.check_100_plus(ctx, number) File "/.../cat38/lib/python3.8/site-packages/redbot/cogs/cleanup/cleanup.py", line 55, in check_100_plus number=humanize_number(number) File "/.../cat38/lib/python3.8/site-packages/redbot/core/utils/chat_formatting.py", line 536, in humanize_number return format_decimal(val, locale=get_babel_regional_format(override_locale)) File "/.../cat38/lib/python3.8/site-packages/babel/numbers.py", line 415, in format_decimal return pattern.apply( File "/.../cat38/lib/python3.8/site-packages/babel/numbers.py", line 996, in apply number = self._quantize_value(value, locale, frac_prec) File "/.../cat38/lib/python3.8/site-packages/babel/numbers.py", line 1065, in _quantize_value rounded = value.quantize(quantum) decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>] The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 903, in invoke await ctx.command.invoke(ctx) File "/.../cat38/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 825, in invoke await super().invoke(ctx) File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1329, in invoke await ctx.invoked_subcommand.invoke(ctx) File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/core.py", line 859, in invoke await injected(*ctx.args, **ctx.kwargs) File "/.../cat38/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidOperation: [<class 'decimal.InvalidOperation'>] ``` #### How can we reproduce this issue? Seems like a babel issue, but try with a very large number like `999999999999999999999999999999999999999999`. I didn't determine where the large number cutoff was. Seems to do just fine with 2^64-1 and values slightly above it too.
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#4619
No description provided.