Skip to content

Guzzle error with blank Address field using Nominatim geocoding #413

@iparr

Description

@iparr

When a user enters a space ( ) or a question mark (?) into the 'Full Address' field I get the following error:

GuzzleHttp\Exception\ClientException
Client error: `GET https://nominatim.openstreetmap.org/search?format=jsonv2&limit=1&accept-language=en&q=%20` resulted in a `400 Bad Request` response:
{"error":{"code":400,"message":"Nothing to search for."}}

I can of course code defensively around this in Twig on the front-end but this also appears in the dashboard which means it's difficult to put right as it becomes re-edit the field.

To fix this I switched the field type from 'Map' to plaintext, emptied the field and then put the field type back - but this feels a little dangerous! I realised that if I switch the Geocoding service to 'Google Maps' this is now editable again - but with an EU client I'm not sure this is ideal.

It would be nice for this (wonderful) plugin to work out-of-the-box without having to use an API key.

Note: I've used this setup for a long time and only recently came across this problem. I think Nominatim have changed how their system works and this plugin needs to take these errors being returned into account. If it just ignored them then I think we'd be fine but I dunno I'm not a plugin author I'm afraid.

I have tried this in a couple of environments:

  • One local using Valet on Mac: (Craft Pro 5.7.1.0 / PHP 8.4.7 / MySQL 9.3 / Nginx 1.27.5)
  • One production using a Ubuntu LEMP stack: (Craft Pro 5.6.17 / PHP 8.4.6 / MySQL 8.0.42 / Nginx 1.26.3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions