studioespresso / craft-easyaddressfield

Easy Address Field is the easiest way to add an address to your entries. Enable the fields you want for the address, automatically get the coordinates for an address and place the marker exactly where you want it.
https://plugins.craftcms.com/easy-address-field
Other
3 stars 3 forks source link

[STU-165] Request to openstreetmap failed with Access blocked #37

Closed mike-moreau closed 1 month ago

mike-moreau commented 2 months ago

I've getting the error when attempting to use an Easy Address Field version 4.0.8 on Craft 4.9.4

Screenshot 2024-07-11 at 10 20 10 PM

Looks like this in the logs:

(GuzzleHttp\\Exception\\ClientException(code: 403): Client error: `GET http://nominatim.openstreetmap.org//search?format=json&countrycodes=US&state=&city=&postalcode=&street=+&limit=1&polygon_geojson=1&addressdetails=1` resulted in a `403 Forbidden` response:
<html>
<head>
<title>Access blocked</title>
</head>
<body>
<h1>Access blocked</h1>

<p>You have been blocked because you (truncated...)
 at .../vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)"} 

Is this an issue on their end, or the plugin itself?

STU-165

janhenckens commented 2 months ago

Hey @mike-moreau, that's an issue on the OpenStreetMaps side but the plugin could probably handle the error better (saving a new entry can also cause the page to cause when this error happens).

I'll try to get an update out with better error handling this week, and secondarily I have a look at adding another service/option for Geolocation to the plugin (we had Google Geocoding in the past, might add that in again).

smockensturm commented 1 month ago

Hi. Can we get an update or a workaround here please? Seems like we can no longer save entries with this field in them.

janhenckens commented 1 month ago

Hey @smockensturm, I have an update out for the Craft 4 version that addresses this but still have to add that to the Craft 5 version.

If you're Craft 4 you can update tot 4.0.9 - for Craft 5 I'll try to have an update out by Friday!

smockensturm commented 1 month ago

Cool. Thank you @janhenckens Any way I can get this into Craft 3.9.13?

janhenckens commented 1 month ago

Yeps, since this crash is pretty inconvenient I added it to Craft 3 as well. Fixed in 3.1.2!

smockensturm commented 1 month ago

Appreciate it @janhenckens Updated. But we're having a devil of a time with the OSM errors.

Attempt to read property "name" on null

What are we doing wrong? This is happening on new entries with this field type. Older entries (with address data) re-save just fine.

janhenckens commented 1 month ago

@smockensturm Could you shared the full stack trace of the error?

smockensturm commented 1 month ago

Sure thing @janhenckens Here you go.

yii\base\ErrorException: Attempt to read property "name" on null in /Users/stevemockensturm/Documents/sites/healthpartners/vendor/studioespresso/craft-easyaddressfield/src/services/FieldService.php:46
Stack trace:
#0 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/craftcms/cms/src/web/ErrorHandler.php(87): yii\base\ErrorHandler->handleError(2, 'Attempt to read...', '/Users/stevemoc...', 46)
#1 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/studioespresso/craft-easyaddressfield/src/services/FieldService.php(46): craft\web\ErrorHandler->handleError(2, 'Attempt to read...', '/Users/stevemoc...', 46)
#2 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/studioespresso/craft-easyaddressfield/src/fields/EasyAddressFieldField.php(208): studioespresso\easyaddressfield\services\FieldService->saveField(Object(studioespresso\easyaddressfield\fields\EasyAddressFieldField), Object(craft\elements\Entry))
#3 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/craftcms/cms/src/base/Element.php(4205): studioespresso\easyaddressfield\fields\EasyAddressFieldField->afterElementSave(Object(craft\elements\Entry), false)
#4 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/craftcms/cms/src/elements/Entry.php(1712): craft\base\Element->afterSave(false)
#5 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/craftcms/cms/src/services/Elements.php(2732): craft\elements\Entry->afterSave(false)
#6 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/craftcms/cms/src/services/Elements.php(785): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, false, true)
#7 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/craftcms/cms/src/controllers/EntriesController.php(409): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#8 [internal function]: craft\controllers\EntriesController->actionSaveEntry(false)
#9 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#10 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#11 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('save-entry', Array)
#12 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/craftcms/cms/src/web/Application.php(295): yii\base\Module->runAction('entries/save-en...', Array)
#13 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/craftcms/cms/src/web/Application.php(608): craft\web\Application->runAction('entries/save-en...', Array)
#14 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/craftcms/cms/src/web/Application.php(274): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#15 /Users/stevemockensturm/Documents/sites/healthpartners/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#16 /Users/stevemockensturm/Documents/sites/healthpartners/public/index.php(22): yii\base\Application->run()
#17 /Users/stevemockensturm/.composer/vendor/laravel/valet/server.php(250): require('/Users/stevemoc...')
#18 {main}
janhenckens commented 1 month ago

Hey @smockensturm, could you try updating to 3.1.3 to see if that fixes this?

smockensturm commented 1 month ago

Legend! @janhenckens thank you so, so much for the extra effort.

janhenckens commented 1 month ago

Cheers :)

wolf-ms commented 2 weeks ago

Hello, I'm encountering a similar issue while using v.4.0.10 on Craft 4.11.5.

`yii\base\ErrorException: Attempt to read property "name" on null in /var/www/html/vendor/studioespresso/craft-easyaddressfield/src/services/FieldService.php:48 Stack trace:

0 /var/www/html/vendor/craftcms/cms/src/web/ErrorHandler.php(79): yii\base\ErrorHandler->handleError(2, 'Attempt to read...', '/var/www/html/v...', 48)

1 /var/www/html/vendor/studioespresso/craft-easyaddressfield/src/services/FieldService.php(48): craft\web\ErrorHandler->handleError(2, 'Attempt to read...', '/var/www/html/v...', 48)

2 /var/www/html/vendor/studioespresso/craft-easyaddressfield/src/fields/EasyAddressFieldField.php(201): studioespresso\easyaddressfield\services\FieldService->saveField(Object(studioespresso\easyaddressfield\fields\EasyAddressFieldField), Object(craft\elements\Entry))

3 /var/www/html/vendor/craftcms/cms/src/base/Element.php(5164): studioespresso\easyaddressfield\fields\EasyAddressFieldField->afterElementSave(Object(craft\elements\Entry), false)

4 /var/www/html/vendor/craftcms/cms/src/elements/Entry.php(2023): craft\base\Element->afterSave(false)

5 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(3461): craft\elements\Entry->afterSave(false)

6 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1114): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), false, true, true, Array, false, false)

7 /var/www/html/vendor/craftcms/cms/src/services/Drafts.php(382): craft\services\Elements->saveElement(Object(craft\elements\Entry), false)

8 /var/www/html/vendor/craftcms/cms/src/services/Drafts.php(318): craft\services\Drafts->removeDraftData(Object(craft\elements\Entry))

9 /var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php(1510): craft\services\Drafts->applyDraft(Object(craft\elements\Entry))

10 [internal function]: craft\controllers\ElementsController->actionApplyDraft()

11 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

12 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)

13 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('apply-draft', Array)

14 /var/www/html/vendor/craftcms/cms/src/web/Application.php(340): yii\base\Module->runAction('elements/apply-...', Array)

15 /var/www/html/vendor/craftcms/cms/src/web/Application.php(639): craft\web\Application->runAction('elements/apply-...', Array)

16 /var/www/html/vendor/craftcms/cms/src/web/Application.php(302): craft\web\Application->_processActionRequest(Object(craft\web\Request))

17 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))

18 /var/www/html/web/index.php(12): yii\base\Application->run()

19 {main}`

janhenckens commented 1 week ago

I created a new issue for this @wolf-ms => https://github.com/studioespresso/craft-easyaddressfield/issues/39