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

tracking api 500 #410

Closed
jacobshilitz opened this issue Aug 2, 2023 · 0 comments · Fixed by #413
Closed

tracking api 500 #410

jacobshilitz opened this issue Aug 2, 2023 · 0 comments · Fixed by #413
Assignees
Labels
bug Something isn't working karrio api

Comments

@jacobshilitz
Copy link
Collaborator

Describe the bug
the api to get tracking id return the following error:

{
    "errors": [
        {
            "message": "Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f81e4bacd00>."
        }
    ]
}

To Reproduce
Steps to reproduce the behavior:
do i get with a valid tracking_id http://localhost:5002/v1/trackers/trk_8f3b5d329864483f82d2c55d98774607

Expected behavior
it should return the tracking details even without auth

api        | ERROR exceptions.py 49 Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f7ac3f03610>.
api        | Traceback (most recent call last):
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2053, in get_prep_value
api        |     return int(value)
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/contrib/auth/models.py", line 437, in __int__
api        |     raise TypeError(
api        | TypeError: Cannot cast AnonymousUser to int. Are you trying to use it in place of User?
api        |
api        | The above exception was the direct cause of the following exception:
api        |
api        | Traceback (most recent call last):
api        |   File "/karrio/venv/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
api        |     response = handler(request, *args, **kwargs)
api        |   File "/karrio/venv/lib/python3.10/site-packages/karrio/server/manager/views/trackers.py", line 255, in get
api        |     return Response(serializers.TrackingStatus(trackers.first()).data)
api        |   File "/karrio/venv/lib/python3.10/site-packages/rest_framework/serializers.py", line 555, in data
api        |     ret = super().data
api        |   File "/karrio/venv/lib/python3.10/site-packages/rest_framework/serializers.py", line 253, in data
api        |     self._data = self.to_representation(self.instance)
api        |   File "/karrio/venv/lib/python3.10/site-packages/rest_framework/serializers.py", line 509, in to_representation
api        |     attribute = field.get_attribute(instance)
api        |   File "/karrio/venv/lib/python3.10/site-packages/rest_framework/fields.py", line 446, in get_attribute
api        |     return get_attribute(instance, self.source_attrs)
api        |   File "/karrio/venv/lib/python3.10/site-packages/rest_framework/fields.py", line 96, in get_attribute
api        |     instance = getattr(instance, attr)
api        |   File "/karrio/venv/lib/python3.10/site-packages/karrio/server/manager/models.py", line 547, in carrier_name
api        |     return typing.cast(Carrier, self.tracking_carrier).data.carrier_name
api        |   File "/karrio/venv/lib/python3.10/site-packages/karrio/server/providers/models/carrier.py", line 149, in data
api        |     config=getattr(self.config, "config", None),
api        |   File "/karrio/venv/lib/python3.10/site-packages/karrio/server/providers/models/carrier.py", line 199, in config
api        |     config = self.__class__.resolve_config(self)
api        |   File "/karrio/venv/lib/python3.10/site-packages/karrio/server/providers/models/carrier.py", line 241, in resolve_config
api        |     return queryset.filter(
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1436, in filter
api        |     return self._filter_or_exclude(False, args, kwargs)
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1454, in _filter_or_exclude
api        |     clone._filter_or_exclude_inplace(negate, args, kwargs)
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1461, in _filter_or_exclude_inplace
api        |     self._query.add_q(Q(*args, **kwargs))
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1534, in add_q
api        |     clause, _ = self._add_q(q_object, self.used_aliases)
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1565, in _add_q
api        |     child_clause, needed_inner = self.build_filter(
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1480, in build_filter
api        |     condition = self.build_lookup(lookups, col, value)
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1307, in build_lookup
api        |     lookup = lookup_class(lhs, rhs)
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/lookups.py", line 27, in __init__
api        |     self.rhs = self.get_prep_lookup()
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/fields/related_lookups.py", line 166, in get_prep_lookup
api        |     self.rhs = target_field.get_prep_value(self.rhs)
api        |   File "/karrio/venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2055, in get_prep_value
api        |     raise e.__class__(
api        | TypeError: Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f7ac3f03610>.
api        | ERROR log.py 241 Internal Server Error: /v1/trackers/trk_e8d2773e1e85466099f32f08db104797
@danh91 danh91 self-assigned this Aug 2, 2023
@danh91 danh91 added bug Something isn't working karrio api labels Aug 2, 2023
@danh91 danh91 linked a pull request Aug 23, 2023 that will close this issue
@danh91 danh91 mentioned this issue Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working karrio api
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants