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

attachment_number must be null for a main PACER document. #4706

Open
sentry-io bot opened this issue Nov 19, 2024 · 0 comments
Open

attachment_number must be null for a main PACER document. #4706

sentry-io bot opened this issue Nov 19, 2024 · 0 comments

Comments

@sentry-io
Copy link

sentry-io bot commented Nov 19, 2024

PR #4703 introduced stricter validation in the RECAPDocument model to ensure data integrity by preventing main PACER documents from having attachment numbers. After merging it, we started getting some validation errors, as it appears that there are existing RECAPDocument records in the database that violate these rules due to historical data inconsistencies. Specifically, we have:

  • Almost 3,000 RECAPDocument instances where attachment_number is set (greater than 0), but document_type is marked as a main PACER document (PACER_DOCUMENT). These are probably attachments that didn't have their document_type updated.
  • Some RECAPDocument instances where attachment_number is 0 and document_type is also PACER_DOCUMENT. These are probably main documents that were wrongly assigned an attachment_number=0 by API users?

This means if some other task is trying to update one of these instances without updating neither the attachment number nor the document type, it will raise an error.

Before debugging any further we should probably clean up the database by fixing the inconsistent instances described above. To do this, we can update the document_type=ATTACHMENT to the ones with attachment numbers > 0:

RECAPDocument.objects.filter(attachment_number__gt=0, document_type=RECAPDocument.PACER_DOCUMENT).update(document_type=RECAPDocument.ATTACHMENT)

And we should change the attachment_number=None to the main PACER docs:

RECAPDocument.objects.filter(attachment_number=0, document_type=RECAPDocument.PACER_DOCUMENT).update(attachment_number=None)

--

Sentry Issue: COURTLISTENER-8MY

Filed by @elisa-a-v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants