pulp / pulpcore

Pulp 3 pulpcore package https://pypi.org/project/pulpcore/
GNU General Public License v2.0
309 stars 116 forks source link

500 error when the listing all domains and filtering by name 'default' #5364

Open dkliban opened 6 months ago

dkliban commented 6 months ago

pulpcore 3.52.0 is producing a 500 error when the listing all domains and filtering by name 'default'.

The default domain has S3 configured.

pulp [da4add42-2e9c-4c30-8349-37c4ddeb945a]: django.request:ERROR: Internal Server Error: /api/pulp/default/api/v3/domains/
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/rest_framework/fields.py", line 439, in get_attribute
    return get_attribute(instance, self.source_attrs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/fields.py", line 104, in get_attribute
    instance = instance[attr]
KeyError: 'location'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/viewsets.py", line 124, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/mixins.py", line 43, in list
    return self.get_paginated_response(serializer.data)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 795, in data
    ret = super().data
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 249, in data
    self._data = self.to_representation(self.instance)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 713, in to_representation
    return [
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 714, in <listcomp>
    self.child.to_representation(item) for item in iterable
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 538, in to_representation
    ret[field.field_name] = field.to_representation(attribute)
  File "/usr/local/lib/python3.9/site-packages/pulpcore/app/serializers/domain.py", line 342, in to_representation
    return serializer.data
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 571, in data
    ret = super().data
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 249, in data
    self._data = self.to_representation(self.instance)
  File "/usr/local/lib/python3.9/site-packages/pulpcore/app/serializers/domain.py", line 46, in to_representation
    return super().to_representation(instance)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 525, in to_representation
    attribute = field.get_attribute(instance)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/fields.py", line 472, in get_attribute
    raise type(exc)(msg)
KeyError: "Got KeyError when attempting to get a value for field `location` on serializer `FileSystemSettingsSerializer`.\nThe serializer field might be named incorrectly and not match any attribute or key on the `dict` instance.\nOriginal exception text was: 'location'."
('pulp [da4add42-2e9c-4c30-8349-37c4ddeb945a]: ::ffff:10.128.4.159 - contentsources [13/May/2024:08:05:19 +0000] "GET /api/pulp/default/api/v3/domains/?name=default HTTP/1.1" 500 145 "-" "OpenAPI-Generator/de24b382d968bd5ed3a4252b36e47596388ab51b7a98d596b8e3294aa65e495a/go"',)
dkliban commented 6 months ago

The reason this worked before was because DEFAULT_FILE_STORAGE was being defined in setttings.py and now it is being specified as PULP_DEFAULT_FILE_STORAGE environment variable.

dkliban commented 6 months ago

I filed a dynaconf issue https://github.com/dynaconf/dynaconf/issues/1097

decko commented 5 months ago

@dkliban weren't able to reproduce this in a dev environment. 😢

rochacbruno commented 5 months ago

I added a comment to the issue https://github.com/dynaconf/dynaconf/issues/1097#issuecomment-2205773190