From f4356168b4ce6eb791b739dd7badfba7c2d79501 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Mon, 10 Mar 2025 17:45:18 +0000 Subject: [PATCH] Check if the query is nil when using the address-search api --- app/controllers/address_search_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/address_search_controller.rb b/app/controllers/address_search_controller.rb index 90d813d6d..4fc8d997a 100644 --- a/app/controllers/address_search_controller.rb +++ b/app/controllers/address_search_controller.rb @@ -5,7 +5,9 @@ class AddressSearchController < ApplicationController def index query = params[:query] - if query.match?(/\A\d+\z/) && query.length > 5 + if query.nil? + render json: { error: "Query cannot be blank." }, status: :bad_request + elsif query.match?(/\A\d+\z/) && query.length > 5 # Query is all numbers and greater than 5 digits, assume it's a UPRN service = UprnClient.new(query) service.call