-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Unique constraint error in create_page_preview #34
Comments
Do you have a reliable way to reproduce this? My colleague reported that he was able to trigger this error in a way that would not seem to be caused by previews being created in rapid succession. I'm asking for more details, but here is how he described it:
|
@Scotchester in normal use, no, but my unit test in #35 reliably hits it. I only saw one real live occurrence of it in my app logs. I think if you generated 2 previews of the same page with different JSON in the same second you'll hit it, due to use of TimestampSigner. |
create_page_preview
is calling get_or_create without passing the non-unique values as defaults. This leads to a unique constraint error, egdjango.db.utils.IntegrityError: UNIQUE constraint failed: wagtail_headless_preview_pagepreview.token
if it's called twice when the signer returns the same value (eg if it's called twice in the same second).wagtail-headless-preview/src/wagtail_headless_preview/models.py
Lines 64 to 80 in f87b2b5
One solution would be pass defaults to get_or_create, but I think maybe it'd be better to call update_page_preview regardless?
The text was updated successfully, but these errors were encountered: