Repository navigation
fix(discord-command-bot): fix setup.py script import and send json payload - #494
Closed
sundeep8967 wants to merge 1 commit into
Closed
sundeep8967 wants to merge 1 commit into
sundeep8967 wants to merge 1 commit into
Conversation
…yload When running setup.py as a script via build command `python src/setup.py`, the relative import `from .utils import throw_if_missing` raised ImportError (attempted relative import with no known parent package). Fallback to absolute import `from utils import throw_if_missing` when executed directly as a script. Additionally, send the command registration payload using `json=` instead of `data=` to ensure Discord's API receives a valid JSON body. Fixes appwrite#491 Signed-off-by: sundeep8967 <sundeep8967@gmail.com>
🟢 Tier S · Ready to merge
The Python Discord command setup script now falls back to importing its utility when run directly, and sends the command registration payload as JSON. This supports the documented build invocation and Discord’s expected request format.
Note @sundeep8967 does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve. 📂 Walkthrough · 1
Reviewed |
Author
|
Resolved upstream via #499 merged into main. Closing this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When Appwrite builds the Python variant of
discord-command-botviapip install -r requirements.txt && python src/setup.py:from .utils import throw_if_missingfails withImportError: attempted relative import with no known parent packagebecause Python runs the file directly as a top-level script.setup.pysentdata={...}while settingContent-Type: application/json. Discord expects a JSON string body, so this should be sent usingjson={...}.Solution
ImportError, ValueErroron the relative import and fall back to top-levelfrom utils import throw_if_missingwhen executed directly as a script.json={...}inrequests.post(...)so the command payload is properly serialized.Fixes #491