freelawproject / courtlistener

A fully-searchable and accessible archive of court data including growing repositories of opinions, oral arguments, judges, judicial financial records, and federal filings.
https://www.courtlistener.com
Other
550 stars 151 forks source link

Update Django to 5.1.2 and update dependencies #4568

Closed ttys0dev closed 1 month ago

ttys0dev commented 1 month ago

Some more dependency updates.

mlissner commented 1 month ago

Can you post some release notes, please? That makes review a ton easier.

mlissner commented 1 month ago

This LGTM, pending Alberto's last review. Alberto, if you want to merge, that'd be great.

ttys0dev commented 1 month ago

rebased

albertisfu commented 1 month ago

I reviewed this in detail, and it looks good except for the django-storages update. It breaks file operations, at least in development.

For instance, I'm encountering an issue during a file upload, specifically during a HEAD operation:

ClientError: An error occurred (400) when calling the HeadObject operation: Bad Request
  File "django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
  File "django/core/handlers/base.py", line 253, in _get_response_async
    response = await wrapped_callback(
  File "django/contrib/admin/options.py", line 718, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "django/utils/decorators.py", line 188, in _view_wrapper
    result = _process_exception(request, e)
  File "django/utils/decorators.py", line 186, in _view_wrapper
    response = view_func(request, *args, **kwargs)
  File "django/views/decorators/cache.py", line 80, in _view_wrapper
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/sites.py", line 241, in inner
    return view(request, *args, **kwargs)
  File "django/contrib/admin/options.py", line 1964, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "django/utils/decorators.py", line 48, in _wrapper
    return bound_method(*args, **kwargs)
  File "django/utils/decorators.py", line 188, in _view_wrapper
    result = _process_exception(request, e)
  File "django/utils/decorators.py", line 186, in _view_wrapper
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/options.py", line 1820, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "django/contrib/admin/options.py", line 1871, in _changeform_view
    self.save_model(request, new_object, form, not add)
  File "django/contrib/admin/options.py", line 1294, in save_model
    obj.save()
  File "cl/search/models.py", line 1629, in save
    super().save(update_fields=update_fields, *args, **kwargs)
  File "django/db/models/base.py", line 891, in save
    self.save_base(
  File "model_utils/tracker.py", line 426, in inner
    return original(instance, *args, **kwargs)
  File "django/db/models/base.py", line 997, in save_base
    updated = self._save_table(
  File "django/db/models/base.py", line 1124, in _save_table
    (getattr(self, f.attname) if raw else f.pre_save(self, False)),
  File "django/db/models/fields/files.py", line 338, in pre_save
    file.save(file.name, file.file, save=False)
  File "django/db/models/fields/files.py", line 99, in save
    self.name = self.storage.save(name, content, max_length=self.field.max_length)
  File "django/core/files/storage/base.py", line 44, in save
    name = self.get_available_name(name, max_length=max_length)
  File "cl/lib/storage.py", line 83, in get_available_name
    return get_name_by_incrementing(self, name, max_length)
  File "cl/lib/storage.py", line 52, in get_name_by_incrementing
    while instance.exists(name):
  File "storages/backends/s3.py", line 587, in exists
    self.connection.meta.client.head_object(Bucket=self.bucket_name, Key=name)
  File "botocore/client.py", line 569, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "botocore/client.py", line 1023, in _make_api_call
    raise error_class(parsed_response, operation_name)

https://freelawproject.sentry.io/issues/5991462937/

Initially, I thought the issue was related to the boto3 update, but it's not.

I confirmed the issue is specific to django-storages 1.14.4, as version 1.14.3 works correctly.

The issue could be related to https://github.com/jschneier/django-storages/issues/1437.

We need to confirm whether this is a permission issue with developer credentials, a problem with environment variable settings that need to be adjusted, or a bug in django-storages.

For now, I think if we want this to be merged, we can downgrade django-storages to version 1.14.3.

ttys0dev commented 1 month ago

For now, I think if we want this to be merged, we can downgrade django-storages to version 1.14.3.

Downgraded to 1.14.3.

albertisfu commented 1 month ago

Downgraded to 1.14.3.

Thanks merging this one. And I'll open an issue regarding 1.14.4 issue.