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.

revert: display information about IntegrityError

See original GitHub issue

It would be good to have the information about the IntegrityError in the error message, instead of the generic “missing dependency”:

> …/Vcs/django-reversion/reversion/models.py(32)

  24     def _safe_revert(versions):                                                                                                                                                          
  25         unreverted_versions = []                                                                                                                                                         
  26         __import__('pdb').set_trace()                                                                                                                                                    
  27         for version in versions:                                                                                                                                                         
  28             try:                                                                                                                                                                         
  29                 with transaction.atomic(using=version.db):                                                                                                                               
  30                     version.revert()                                                                                                                                                     
  31             except (IntegrityError, ObjectDoesNotExist):                                                                                                                                 
  32  ->             unreverted_versions.append(version)                                                                                                                                      
  33         if len(unreverted_versions) == len(versions):                                                                                                                                    
  34             raise RevertError(ugettext("Could not save %(object_repr)s version - missing dependency.") % {                                                                               
  35                 "object_repr": unreverted_versions[0],                                                                                                                                   
  36             })                                                                                                                                                                           
  37         if unreverted_versions:                                                                                                                                                          
  38             _safe_revert(unreverted_versions)                                                                                                                                            
 IntegrityError: duplicate key value violates unique constraint "app_subscriptionplan_organization_id_66f20bda_uniq"
DETAIL:  Key (organization_id, name)=(77, WEEKLY) already exists.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
etianencommented, Sep 5, 2018

I’d take a pull request to add logger.exception() calls for the errors.

I’m not so keen on displaying the postgres error message in the admin, as it could be very big and intimidating for admin users (who are typically not database-savvy).

On 5 September 2018 at 15:15, Daniel Hahler notifications@github.com wrote:

Maybe it could be logged in general (logger.exception), and attached/wrapped into the RevertError to be displayed in the admin only?

To be clear: I am only talking about the “if len(unreverted_versions) == len(versions)” case.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/etianen/django-reversion/issues/750#issuecomment-418746780, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCJ7KmzgTCaA9hvDbXlzlj14U_fR2ks5uX9yVgaJpZM4WZkpl .

0reactions
tonycommented, Sep 21, 2022

@blueyed @etianen

I’ve followed up with a PR to this in #921

This was some time ago, but I’ve bumped into this a couple of times over the years - and always had to omit fields and just save everything.

Adding a logging.exception() to the IntegrityError instantly diagnosed this in my case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django - Dealing With Integrity Error And Showing Error Pop up
I've tried to add exception handling using code below but it is not working. try: if request.method == 'POST': properties_Form = InputForm( ...
Read more >
Backup and Restore | InterSystems IRIS Data Platform 2022.2
Explains the role of backup and restore in protecting data integrity and recovering from system failures and disasters on InterSystems IRIS data platform, ......
Read more >
Important notes — Borg - Deduplicating Archiver 1.2.2 ...
This section provides information about security and corruption issues. ... cache. related change: add archive name to calc_stats progress display. docs:.
Read more >
Display settings - Caseware
You are here: Help Topics > Setup > Display settings. Display settings. Customize how you view documents using various settings and screen modifications....
Read more >
How to show validation error in my form instead of getting ...
IntegrityError at /users/admin/add-project/ duplicate key value violates ... display link to object info page instead of edit form , in records change list?...
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