cheran-senthil / cheran-senthil/TLE

Error when checking starboard message

Open
#456 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
337
Forks
234
PR merge metrics
No merged PRs in 30d

Description

If `check_exists_starboard_message` is called when the message to check is on the starboard, it will throw the following error:
```
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "/home/user/.local/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/user/tle/cogs/starboard.py", line 35, in on_raw_reaction_add
await self.check_and_add_to_starboard(starboard_channel_id, payload)
File "/home/user/tle/cogs/starboard.py", line 99, in check_and_add_to_starboard
if self.db.check_exists_starboard_message(message.id):
File "/home/user/tle/util/db/user_db_conn.py", line 481, in check_exists_starboard_message
res = self.conn.execute(query, (original_msg_id,)).fetchone()
File "/home/user/tle/util/db/user_db_conn.py", line 60, in namedtuple_factory
return Row(*row)
TypeError: () takes 1 positional argument but 2 were given
```

This is probably caused by the query `SELECT 1 FROM starboard_message WHERE original_msg_id = ?` ([source](https://github.com/cheran-senthil/TLE/blob/master/tle/util/db/user_db_conn.py#L478-L480)): if it returns a row, then there would have a column named `1`, which is not an identifier and makes [`namedtuple_factory`](https://github.com/cheran-senthil/TLE/blob/master/tle/util/db/user_db_conn.py#L58) create an incorrect number of fields.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in tle/util/db/user_db_conn.py at check_exists_starboard_message and inspect namedtuple_factory, then follow the call from tle/cogs/starboard.py. Reproduce the check for a message already on the starboard and confirm the query result no longer raises the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
database
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.