question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Raises an exception if a duplcate status is posted, documentation suggests otherwise

See original GitHub issue

If update_status is called with a duplicate status, a TweepError is raised:

File "/usr/local/lib/python2.7/dist-packages/tweepy/api.py", line 194, in update_status
    )(post_data=post_data, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 245, in _call
    return method.execute()
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 229, in execute
    raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{u'message': u'Status is a duplicate.', u'code': 187}]

Although the documentation says “Statuses that are duplicates or too long will be silently ignored.”

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
fitnrcommented, Jan 25, 2018

You can use an if block inside the except block to specify different treatment of different error types.

try:
    api.update_status(duplicate_text)
except tweepy.TweepError as error:
    if error.api_code == 187:
        # Do something special
        print('duplicate message')
   else:
       raise error

Twitter is preventing you from posting the duplicate text, so the only way around that is to just wait.

0reactions
KshitijKarnawatcommented, Jul 2, 2020

Just change the contents of api.update_status and your program should work fine

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does upsert cause a DUPLICATE_VALUE error?
When I upsert two records with identical Name/ID, but otherwise different values, in two separate upsert statement, one record results, as ...
Read more >
711.3 – Admissibility of Duplicates [Rule 1003] - NC PRO
A duplicate is admissible to the same extent as an original unless (1) a genuine question is raised as to the authenticity of...
Read more >
Catch duplicate entry Exception - java - Stack Overflow
I use spring so we resolve it by org.springframework.dao.DataIntegrityViolationException try { ao_history_repository.save(new AoHistory(.
Read more >
21.7.9 BMF Duplicate Filing Conditions - IRS
If you determine the return is an amended/corrected/adjusted return, input a Transaction Code (TC) 971 Action Code (AC) 010 to set the -A...
Read more >
Error handling with DynamoDB - AWS Documentation
If the request is unsuccessful, DynamoDB returns an error. Each error has three components: An HTTP status code (such as 400 ). An...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found