Closed (fixed)
Project:
Geocoder
Version:
8.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 Feb 2026 at 18:12 UTC
Updated:
17 Aug 2026 at 22:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
solideogloria commentedComment #3
itamair commentedThis is exactly what it is supposed to happen and it is happening actually ...
Could you provide evidence that is not?
What is your specific setup, where an empty string is trying to be Geocoded, arriving at this point in process workflow:
https://git.drupalcode.org/project/geocoder/-/blob/8.x-4.x/src/Geocoder....
Comment #4
solideogloria commentedEmpty string is a string, so it will call
->geocode($address), even though we already know that it won't be successful if$addressis an empty string.The call could instead be skipped completely for empty string, before the for loop. Personally, I think it shouldn't even throw an exception in that case. Just return NULL. This is because the only way to decide to skip geocoding during the alter hook is to set the address string to empty string. However, this causes an exception to be thrown and logged every time that happens.
Comment #6
itamair commentedOk, thanks @solideogloria
this have sense to me also.
I verified that using the Geocode service throughout the geocoding of a field entity value (thus with the geocoder_field module) that code (from the Geocoder service) is never reached in case the string being geocoded is empty, because of this:
https://git.drupalcode.org/project/geocoder/-/blob/8.x-4.x/modules/geoco...
But it could still be the case of geocoding operations directly/programmatically triggered via the APIs:
$addressCollection = \Drupal::service('geocoder')->geocode($address, $providers);Thus it could be appropriate not to perform it in case the $address is an empty string, after all its possible alters.
And it still makes sense to me not to silently fail it, but log a warning message regarding the attempt to Geocode as empty source …
Committed into origin/8.x-4.x dev branch, will be part of the next incoming module release.
Comment #8
solideogloria commentedAlright, thank you.
Comment #10
solideogloria commentedPatch file until a new release is created with the changes.
Comment #11
solideogloria commented@itamair I think this causes an error:
Does something need to be added to the following
elseifto verify that$address instanceof GeocodeQuery?