You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No values are expected at the end of this URL. If we were writing our the URL patterns, we would have written a regex like:
r'^/api/v1/organizations/(?P<pk>[0-9]+)/teams/$'
Thus, Django should simply pass over this pattern in the URL search as not matched. The view shouldn't even be involved here, as the view should never be routed such a request.
Actual result
Server error
[05/Apr/2024 20:52:28] "GET /api/v1/organizations/1/teams/2 HTTP/1.1" 301 0
Internal Server Error: /api/v1/organizations/1/teams/2/
Traceback (most recent call last):
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
return view_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/rest_framework/viewsets.py", line 124, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/rest_framework/mixins.py", line 56, in retrieve
instance = self.get_object()
^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/rest_framework/generics.py", line 100, in get_object
obj = get_object_or_404(queryset, **filter_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/rest_framework/generics.py", line 19, in get_object_or_404
return _get_object_or_404(queryset, *filter_args, **filter_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/shortcuts.py", line 85, in get_object_or_404
return queryset.get(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/db/models/query.py", line 623, in get
clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/db/models/query.py", line 1436, in filter
return self._filter_or_exclude(False, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/db/models/query.py", line 1454, in _filter_or_exclude
clone._filter_or_exclude_inplace(negate, args, kwargs)
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/db/models/query.py", line 1461, in _filter_or_exclude_inplace
self._query.add_q(Q(*args, **kwargs))
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/db/models/sql/query.py", line 1546, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/db/models/sql/query.py", line 1577, in _add_q
child_clause, needed_inner = self.build_filter(
^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/db/models/sql/query.py", line 1427, in build_filter
lookups, parts, reffed_expression = self.solve_lookup_type(arg, summarize)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/db/models/sql/query.py", line 1237, in solve_lookup_type
_, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alancoding/venvs/awx/lib64/python3.11/site-packages/django/db/models/sql/query.py", line 1725, in names_to_path
raise FieldError(
django.core.exceptions.FieldError: Cannot resolve keyword 'teams' into field. Choices are: admins, created, created_by, created_by_id, description, encryptioner, encryptioner_id, has_roles, id, member_roles, modified, modified_by, modified_by_id, name, organization, organization_id, related_fields_test_model_more_teams, related_fields_test_model_teams_with_no_view, resource, roleteamassignment, team_children, team_parents, tracked_users, users
[05/Apr/2024 20:52:28] "GET /api/v1/organizations/1/teams/2/ HTTP/1.1" 500 172747
of course this triggers dynamically generated viewset & serializer for the purpose.
The root problem seems to be that TeamViewSet has all the viewset methods required for vendoring /api/v1/teams/, which includes its internal router automatically adding tails to the URL for detail view and other stuff.
The text was updated successfully, but these errors were encountered:
Reproduce by
./test_app/scripts/bootstrap.sh
Expected result
404 Not Found
No values are expected at the end of this URL. If we were writing our the URL patterns, we would have written a regex like:
r'^/api/v1/organizations/(?P<pk>[0-9]+)/teams/$'
Thus, Django should simply pass over this pattern in the URL search as not matched. The view shouldn't even be involved here, as the view should never be routed such a request.
Actual result
Server error
Commentary
Relevant registration is at:
django-ansible-base/test_app/router.py
Line 14 in 84d7813
of course this triggers dynamically generated viewset & serializer for the purpose.
The root problem seems to be that
TeamViewSet
has all the viewset methods required for vendoring/api/v1/teams/
, which includes its internal router automatically adding tails to the URL for detail view and other stuff.The text was updated successfully, but these errors were encountered: