Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3: Option creation fails if message ID is longer than 32 characters #427

Closed
2 tasks done
tomodachi94 opened this issue Jul 16, 2024 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@tomodachi94
Copy link

tomodachi94 commented Jul 16, 2024

Steps to reproduce

  1. Install Hikari-Lightbulb v3.0.0a5 with the localization extra
  2. Create a translations/en-US/LC_MESSAGES/commands.po file with a message ID with 32 characters or more, like this:
msgid "ext.mediawiki.command.articleRandom.option.number.description"
msgstr "The number of articles to show."
  1. Develop on your bot like normal, and try to use that message ID with a line like this:
    number = lightbulb.integer(
        "ext.mediawiki.command.articleRandom.option.number.name",
        "ext.mediawiki.command.articleRandom.option.number.description",
        localize=True,
    )
  1. See traceback in "Actual result"

Expected result

I should be able to use message IDs longer than 32 characters, considering that Gettext does not appear to have a limitation like this.

Actual result

Lightbulb complains about the key being longer than 32 characters:

E 2024-07-15 21:38:31,742 hikari.event_manager: an exception occurred handling an event (StartingEvent)
Traceback (most recent call last):
  File "/home/me/git/github.com/tomodachi94/dash2/dash/__main__.py", line 25, in on_starting
    await client.load_extensions_from_package(dash.ext)
  File "/home/me/.cache/pypoetry/virtualenvs/dash-6b0j9Q79-py3.11/lib/python3.11/site-packages/lightbulb/client.py", line 495, in load_extensions_from_package
    await self.load_extensions(*extensions)
  File "/home/me/.cache/pypoetry/virtualenvs/dash-6b0j9Q79-py3.11/lib/python3.11/site-packages/lightbulb/client.py", line 403, in load_extensions
    extension = importlib.import_module(path)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/6b1fqdwb3g56j5pazv8zkx9qd0mv3wiz-python3-3.11.9/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/me/git/github.com/tomodachi94/dash2/dash/ext/mediawiki.py", line 48, in <module>
    show_embeds_option = lightbulb.boolean(
                         ^^^^^^^^^^^^^^^^^^
  File "/home/me/.cache/pypoetry/virtualenvs/dash-6b0j9Q79-py3.11/lib/python3.11/site-packages/lightbulb/commands/options.py", line 400, in boolean
    OptionData(
  File "<string>", line 18, in __init__
  File "/home/me/.cache/pypoetry/virtualenvs/dash-6b0j9Q79-py3.11/lib/python3.11/site-packages/lightbulb/commands/options.py", line 114, in __post_init__
    raise ValueError("'name' - must be 1-32 characters")
ValueError: 'name' - must be 1-32 characters

System info

hikari-lightbulb (3.0.0a5)
hikari (2.0.0.dev126) [f65737f4]
located at /nix/store/m1k00v0qvc50hx5yx6zc2pbwnh41h224-python3.11-hikari-2.0.0.dev126/lib/python3.11/site-packages/hikari
CPython 3.11.9 GCC 13.3.0
Linux [REDACTED; was a hostname] 6.6.37 #1-NixOS SMP PREEMPT_DYNAMIC Fri Jul  5 07:34:07 UTC 2024 x86_64

Further info

No response

Checklist

  • I have made sure to remove ANY sensitive information (bot token, passwords, credentials, personal details, etc.).
  • I have searched the issue tracker and have made sure it's not a duplicate. If it is a follow up of another issue, I have specified it.
@tomodachi94 tomodachi94 added the bug Something isn't working label Jul 16, 2024
@tomodachi94 tomodachi94 changed the title v3: Localization fails if key is longer than 32 characters v3: Option creation fails if message ID is longer than 32 characters Jul 16, 2024
@tandemdude
Copy link
Owner

Thank you for your issue - this is fixed on the v3 branch and will be available from the next release. Until then you can install from source if you need it sooner.

@tandemdude
Copy link
Owner

This fix is now released in version 3.0.0a6. Install from PyPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants