I searched Google Hotels for a city that does not exist. It found five hotels.
I typed "hotels in Qwzxvbnmplk" into my Google Hotels scraper to watch it fail. It did not fail. It came back with five hotels near San Antonio, Texas, each with a price, a rating and a map position. This is the story of that answer and the fix. It is also how my fix broke a real capital city, and the small check I now run before I trust any search result. A test that was supposed to fail On 8…
On October 8th, the author was testing inputs that should fail by searching for cities that do not exist. They entered "hotels in Qwzxvbnmplk" into Google Hotels and received five hotel results near San Antonio, Texas, each with prices, ratings, and coordinates. The scraper charged for these priced hotels, even though the search input was nonsensical.
The author discovered that Google always tries to answer a query, even if it cannot find an exact match, by showing hotels nearby. They implemented a fix that resolved the place first, skipped the search if no place was found, and added a field called "resolvedPlace" to identify the understood place. However, this fix broke a real capital city, Prague, as Google sent a page for Prague without its place data.
The author then added a retry mechanism for missing places, but this still led to incorrect results. The author concludes by providing a simple check that can be used to validate the answers from various sources, such as geocoders, search APIs, or entity lookups.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.