Freika / dawarich

Self-hosted alternative to Google Location History (Google Maps Timeline)
https://dawarich.app
GNU Affero General Public License v3.0
2.07k stars 44 forks source link

Reverse geocoding always fails `Geocoder::ResponseParseError` #333

Open MeijiRestored opened 1 day ago

MeijiRestored commented 1 day ago

Describe the bug All reverse geocoding tasks fail with Geocoder::ResponseParseError.

Version 0.15.4

Logs

dawarich_sidekiq  | E, [2024-10-16T16:46:54.509796 #119] ERROR -- : Error performing ReverseGeocodingJob (Job ID: d570478e-375c-4b52-92d1-f9734bd4bdaa) from Sidekiq(reverse_geocoding) in 85.58ms: Geocoder::ResponseParseError (Geocoder::ResponseParseError):
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:186:in `raise_error'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:215:in `rescue in parse_json'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:208:in `parse_json'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:225:in `parse_raw_data'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:196:in `fetch_data'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/photon.rb:23:in `results'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/lookups/base.rb:46:in `search'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder/query.rb:11:in `execute'
dawarich_sidekiq  | /var/app/vendor/bundle/ruby/3.3.0/bundler/gems/geocoder-04ee2936a30b/lib/geocoder.rb:22:in `search'
dawarich_sidekiq  | /var/app/app/services/reverse_geocoding/points/fetch_data.rb:15:in `call'
dawarich_sidekiq  | /var/app/app/jobs/reverse_geocoding_job.rb:9:in `perform'
...
dawarich_sidekiq  | 2024-10-16T16:46:54.512Z pid=119 tid=kj3 class=ReverseGeocodingJob jid=0b5f9987fbe98fbf38ad7928 elapsed=0.5 INFO: fail
dawarich_sidekiq  | 2024-10-16T16:46:54.513Z pid=119 tid=kj3 WARN: {"context":"Job raised exception","job":{"retry":true,"queue":"reverse_geocoding","wrapped":"ReverseGeocodingJob","args":[{"job_class":"ReverseGeocodingJob","job_id":"d570478e-375c-4b52-92d1-f9734bd4bdaa","provider_job_id":null,"queue_name":"reverse_geocoding","priority":null,"arguments":["Point",334980],"executions":0,"exception_executions":{},"locale":"en","timezone":"Europe/Brussels","enqueued_at":"2024-10-16T16:35:11.591410395Z","scheduled_at":null}],"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","jid":"0b5f9987fbe98fbf38ad7928","created_at":1729096511.5914497,"enqueued_at":1729097117.906883,"error_message":"Geocoder::ResponseParseError","error_class":"Geocoder::ResponseParseError","failed_at":1729096529.0304668,"retry_count":4,"retried_at":1729096836.6148896}}
dawarich_sidekiq  | 2024-10-16T16:46:54.513Z pid=119 tid=kj3 WARN: Geocoder::ResponseParseError: Geocoder::ResponseParseError
dawarich_sidekiq  | 2024-10-16T16:46:54.513Z pid=119 tid=kj3 WARN: app/services/reverse_geocoding/points/fetch_data.rb:15:in `call'
dawarich_sidekiq  | app/jobs/reverse_geocoding_job.rb:9:in `perform'

Additional context Happens with both default geocoder (Nominatim) and self-hosted Photon instance (served over HTTPS from a remote server). It is happening only since the latest 0.15.4 update.

Here is an example query from my Photon instance in case it could be the issue (probably not since Nominatim fails as well): /reverse?lon=2&lat=50

{
    "features": [
        {
            "geometry": {
                "coordinates": [
                    1.9993273,
                    49.9994663
                ],
                "type": "Point"
            },
            "type": "Feature",
            "properties": {
                "osm_id": 297408537,
                "extent": [
                    1.9961878,
                    50.0094171,
                    1.9996089,
                    49.9881855
                ],
                "country": "France",
                "city": "Bettencourt-Rivière",
                "countrycode": "FR",
                "postcode": "80270",
                "county": "Somme",
                "type": "street",
                "osm_type": "W",
                "osm_key": "highway",
                "osm_value": "tertiary",
                "name": "Cavée du Quesnoy",
                "state": "Hauts-de-France"
            }
        }
    ],
    "type": "FeatureCollection"
}
Tazmanian79 commented 23 hours ago

I can confirm this issue. No more Reverse Geocoding after update to 0.15.4 I also use the photon api

chrisl8 commented 16 hours ago

What does everyone have set for their PHOTON_API_HOST variable?

I know that I had to play around with variations such as:

hostname https://hostname http://hostname:2322 hostname:2322 https://hostname:2322 etc.

@Freika is this possibly because of using the new Geocoder library code https://github.com/Freika/dawarich/issues/300#issuecomment-2414606291 ?

It works great for me without https using: PHOTON_API_HOST=photon:2322

Maybe now only http works and not https?

chrisl8 commented 15 hours ago

@Freika I can confirm that while it now works to contact a photon server via http, it seems unable to contact any photon server via https regardless of how I set up the PHOTON_API_HOST variable.


I think maybe the call to Geocoder needs to specify whether or not to use https now?

https://github.com/Freika/dawarich/blob/0fcc7bde1a7a9b97143ea67252b75a471b08ce60/config/initializers/geocoder.rb#L15

Changing it to this seems to make it work for HTTPS endpoints?

  settings[:photon] = { use_https: true, host: PHOTON_API_HOST }

Although please test it yourself, I'm not 100% sure.

The options for Geocoder seem to be here: https://github.com/alexreisner/geocoder/blob/19f3cd1c717f5670aafaf690aa3b20955822ea88/lib/geocoder/configuration.rb#L53

The use_https part didn't matter/work before when Geocoder only did https, but maybe it matters now?


If that is the fix, then there will need to be more code to either parse the PHOTON_API_HOST variable for the protocol or have a 2nd variable for PHOTON_API_USE_HTTPS.

a-w-1806 commented 7 hours ago

I am having the same issue. I am trying to use Nominatim with REVERSE_GEOCODING_ENABLED: true but no luck. Does the fix mentioned above also help with Nominatim users?