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

Error When Twitter Display Name Is 31+ Characters #28

Closed
jimmybrancaccio opened this issue Jan 8, 2021 · 4 comments · Fixed by #30
Closed

Error When Twitter Display Name Is 31+ Characters #28

jimmybrancaccio opened this issue Jan 8, 2021 · 4 comments · Fixed by #30
Assignees
Labels
bug Something isn't working

Comments

@jimmybrancaccio
Copy link

When a Twitter user's display name is 31+ characters you get the following error:

pleroma_bot - ERROR - Exception occurred
Traceback (most recent call last):
  File "/home/jimmy/.local/lib/python3.8/site-packages/pleroma_bot/cli.py", line 229, in main
    user.update_pleroma()
  File "/home/jimmy/.local/lib/python3.8/site-packages/pleroma_bot/_pleroma.py", line 245, in update_pleroma
    response.raise_for_status()
  File "/home/jimmy/.local/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://domain.com/api/v1/accounts/update_credentials

After some debugging I was able to work around this by updating:

https://github.com/robertoszek/pleroma-twitter-info-grabber/blob/83da9b65e1e4eac35609900ef165f4deb3e22e59/pleroma_bot/_pleroma.py#L196

to:

data = {"note": self.bio_text, "display_name": self.display_name[0:30]}

In my opinion it's less than ideal to just chop away data. Unfortunately what I believe would be the best fix fix would need to come from Mastodon in this case where the character limit on the display_name is upped. It looks like Twitter's display name limit is currently 50 characters.

@robertoszek robertoszek added the bug Something isn't working label Jan 8, 2021
@robertoszek robertoszek self-assigned this Jan 8, 2021
@robertoszek
Copy link
Owner

Hi,
I need to think about how to go about this as Pleroma seems to support 50 characters, so there's parity with Twitter's limit.
Truncating the display name in all cases is not ideal, specially if the target instance happens to support a higher limit.
Ideally I would identify if the target instance is Mastodon and truncate it only on that case, I need to refresh my knowledge on how ActivityPub instances announce themselves.

In the meantime, I published a test release with a quick fix if you want to try it out and let me know if it works in your case:

pip install --index-url https://test.pypi.org/simple/ pleroma-bot --upgrade

@robertoszek
Copy link
Owner

robertoszek commented Jan 8, 2021

Well, I implemented a much cleaner solution based on what platform the instance seems to be (by checking the version it reports back when asked). Here's the commit 8537c7c

I also uploaded it as a test release on PyPi, you can install it with:

pip install --index-url https://test.pypi.org/simple/ pleroma-bot --upgrade

I tested it with a few Mastodon instances, please let me know if it works with your config.

@jimmybrancaccio
Copy link
Author

@robertoszek Awesome! I'll give it a shot soon™!

@robertoszek
Copy link
Owner

Changes promoted to master. Let me know if you experience any issues with the fix implementation.
Cheers!

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

Successfully merging a pull request may close this issue.

2 participants