-
Notifications
You must be signed in to change notification settings - Fork 486
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
revert: display information about IntegrityError #750
Comments
The trouble is, this isn't information that should really be shown to an
end user.
I guess the logs is the correct place for this.
…On 4 September 2018 at 20:04, Daniel Hahler ***@***.***> wrote:
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 "lock8_subscriptionplan_organization_id_66f20bda_uniq"
DETAIL: Key (organization_id, name)=(77, WEEKLY) already exists.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#750>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAJFCFAi8eJ-Y4awDldSTpauaMIdEqWXks5uXs7agaJpZM4WZkpl>
.
|
Isn't it (typically) a staff user, and therefore more OK? |
Maybe it could be logged in general ( To be clear: I am only talking about the "if len(unreverted_versions) == len(versions)" case. |
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 ***@***.***> 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
<#750 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJFCJ7KmzgTCaA9hvDbXlzlj14U_fR2ks5uX9yVgaJpZM4WZkpl>
.
|
This will be helpful @reversion.register users that explicitly declare their fields. Fixes etianen#750
This will be helpful @reversion.register users that explicitly declare their fields. Fixes etianen#750
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 Adding a |
This will be helpful @reversion.register users that explicitly declare their fields. Fixes etianen#750
It would be good to have the information about the IntegrityError in the error
message, instead of the generic "missing dependency":
The text was updated successfully, but these errors were encountered: