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

RSS Import: Issue with KeyError: 'cw' #126

Open
AyotoCorp opened this issue Mar 19, 2023 · 5 comments
Open

RSS Import: Issue with KeyError: 'cw' #126

AyotoCorp opened this issue Mar 19, 2023 · 5 comments

Comments

@AyotoCorp
Copy link

AyotoCorp commented Mar 19, 2023

Having a small issue where the bot will collect tweets while using RSS, but will fail to post because of the following error:

✖ 2023-03-19 13:45:58,341 - pleroma_bot - ERROR - Exception occurred for user, skipping... (cli.py:717) Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/pleroma_bot/cli.py", line 695, in main cw=tweet["cw"] KeyError: 'cw'

Commenting out that section lets it post a few times, but then it stops because of a number of other issues in a series of other lines which I didn't want to mess around with in case it broke further.

@robertoszek
Copy link
Owner

Hi!
Which version of the bot do you have currently installed?
You can check by running:

pleroma-bot --version

The latest release candidate as of now for the bot is v1.2.1rc20, which you can install like so:

pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pleroma-bot==1.2.1rc20

I'm wondering if it still happening on v1.2.1rc20, I made some changes that haven't being merged into the stable version yet about populating cw for RSS feeds.

@AyotoCorp
Copy link
Author

That was on 1.2.0. When I updated it, I got a different error instead during the posting part:

✖ 2023-03-19 23:30:54,211 - pleroma_bot - ERROR - Exception occurred for user, skipping... (cli.py:721) 
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/pleroma_bot/cli.py", line 688, in main
    post_id = user.post(
  File "/usr/local/lib/python3.10/dist-packages/pleroma_bot/_utils.py", line 796, in post
    post_id = self.post_pleroma(tweet, poll, sensitive, media, cw=cw)
  File "/usr/local/lib/python3.10/dist-packages/pleroma_bot/_pleroma.py", line 231, in post_pleroma
    item = media[key][0]
KeyError: '46vkwzdn9pc8socim97'

Which was very similar to the error I got when I commented out the cw line in the previous version.

@robertoszek
Copy link
Owner

Does it make any difference if you clean up the temp folder tweets generated at the path where your config.yml file is?
Do you get the same exact error?
Perhaps there's some orphan files from a previous failed run.

@AyotoCorp
Copy link
Author

It looks like clearing out the tweets folder fixed it, I guess running it previously caused something to get stuck in the tweets that shouldn't have been there. Now I just have an issue where it's not pulling old tweets that were made when the bot wasn't functioning properly and posting them, but that's a separate issue.

@nemobis
Copy link
Contributor

nemobis commented Jun 25, 2023

This happens because some fields are called even if they can be undefined. It could be fixed by making sure those fields are always initialised or by checking before reference. (Small example patch incoming.)

nemobis added a commit to nemobis/pleroma-bot that referenced this issue Jun 25, 2023
Can happen with RSS input.

Addresses issue robertoszek#126
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants