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

TypeError: expected string or bytes-like object in nominatim API client #2495

Closed
timobrembeck opened this issue Oct 30, 2023 · 7 comments · Fixed by #2529
Closed

TypeError: expected string or bytes-like object in nominatim API client #2495

timobrembeck opened this issue Oct 30, 2023 · 7 comments · Fixed by #2529
Assignees
Labels
🐛 bug Something isn't working
Milestone

Comments

@timobrembeck
Copy link
Member

Describe the Bug

Steps to Reproduce

  1. Go to https://admin.integreat-app.de/testumgebung-reg/pois/de/new/
  2. Input something ?
  3. Submit form
  4. See error

Expected Behavior

A POI should be created and the coordinates should correctly be retrieved from the nominatim api

Actual Behavior

An internal server error occurs

Additional Information

Traceback
Oct 30 09:30:52 ERROR   django.request - 500 Internal Server Error: /testumgebung-reg/pois/de/new/
Traceback (most recent call last):
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
  response = get_response(request)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
  response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
  return self.dispatch(request, *args, **kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
  return bound_method(*args, **kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
  return view_func(request, *args, **kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch
  return handler(request, *args, **kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
  return bound_method(*args, **kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
  return view_func(request, *args, **kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/integreat_cms/cms/views/pois/poi_form_view.py", line 166, in post
  if not poi_form.is_valid() or not poi_translation_form.is_valid():
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/forms/forms.py", line 175, in is_valid
  return self.is_bound and not self.errors
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/forms/forms.py", line 170, in errors
  self.full_clean()
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/forms/forms.py", line 373, in full_clean
  self._clean_form()
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/forms/forms.py", line 400, in _clean_form
  cleaned_data = self.clean()
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/integreat_cms/cms/forms/pois/poi_form.py", line 164, in clean
  latitude, longitude = nominatim_api_client.get_coordinates(
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/integreat_cms/nominatim_api/nominatim_api_client.py", line 134, in get_coordinates
  if result := self.search(street=street, postalcode=postalcode, city=city):
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/integreat_cms/nominatim_api/nominatim_api_client.py", line 80, in search
  query_dict["street"] = re.sub(
File "/usr/lib/python3.9/re.py", line 210, in sub
  return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object
@timobrembeck timobrembeck added 🐛 bug Something isn't working 🆘 prio: urgent Needs to be resolved now(?) labels Oct 30, 2023
@timobrembeck timobrembeck added this to the 23Q4 milestone Oct 30, 2023
@timobrembeck timobrembeck removed the 🆘 prio: urgent Needs to be resolved now(?) label Oct 30, 2023
@timobrembeck
Copy link
Member Author

timobrembeck commented Oct 30, 2023

This is not a new bug, but seems to exist for a while and just occurs in some edge cases.

$ sudo zcat /var/log/integreat-cms.log.*.gz | grep "/pois/de/new"
Oct 20 11:43:26 ERROR   django.request - 500 Internal Server Error: /stadtdachau/pois/de/new/
Oct 25 07:36:31 ERROR   django.request - 500 Internal Server Error: /lkneumarkt/pois/de/new/

@JoeyStk
Copy link
Contributor

JoeyStk commented Oct 30, 2023

I tried to find out what the two municipalities did on that date to exactly reproduce it. It only helped me a bit. I noticed that they tried to create

  • a POI from the event form
  • a POI without an exact address number (street name 22-24)
  • a POI in the others category

But I still wasn't able to reproduce it. Maybe one other person can try to reproduce it, and then it might be best to ask the service to ask the municipalities what they were trying to do? :/

@timobrembeck
Copy link
Member Author

It would also be interesting to know who tried to create a poi in the testumgebung today at 09:30:52 UTC...

@JoeyStk
Copy link
Contributor

JoeyStk commented Oct 30, 2023

testumgebung-reg? That would have been me. Why? Did the problem occur at time again?

@timobrembeck
Copy link
Member Author

testumgebung-reg? That would have been me. Why? Did the problem occur at time again?

Yes, this was the original reason why I created the ticket, see the initial traceback of the bug

@JoeyStk
Copy link
Contributor

JoeyStk commented Oct 30, 2023

Ah no, then it wasn't me. I started to reproduce it just after you created the issue. Must have been more like 11:40 then. Ok, then I'm not able to reproduce it

@MizukiTemma
Copy link
Member

How to reproduce: space in "Street and house number"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants