{"record":{"id":"48f22feae4441ec6","repo":"alexreisner/geocoder","slug":"the-query-lookup-name-api-requires-a-key-to-be-configured","errorCode":null,"errorMessage":"The #{query.lookup.name} API requires a key to be configured: #{parts_string.inspect}","messagePattern":"The #(.+?) API requires a key to be configured: #(.+?)","errorType":"exception","errorClass":"Geocoder::ConfigurationError","httpStatus":null,"severity":"error","filePath":"lib/geocoder/lookups/base.rb","lineNumber":333,"sourceCode":"      end\n\n      def use_ssl?\n        if supported_protocols == [:https]\n          true\n        elsif supported_protocols == [:http]\n          false\n        else\n          configuration.use_https\n        end\n      end\n\n      def configure_ssl!(client); end\n\n      def check_api_key_configuration!(query)\n        key_parts = query.lookup.required_api_key_parts\n        if key_parts.size > Array(configuration.api_key).size\n          parts_string = key_parts.size == 1 ? key_parts.first : key_parts\n          raise Geocoder::ConfigurationError,\n            \"The #{query.lookup.name} API requires a key to be configured: \" +\n            parts_string.inspect\n        end\n      end\n\n      ##\n      # Simulate ActiveSupport's Object#to_query.\n      # Removes any keys with nil value.\n      #\n      def hash_to_query(hash)\n        require 'cgi' unless defined?(CGI) && defined?(CGI.escape)\n        hash.collect{ |p|\n          p[1].nil? ? nil : p.map{ |i| CGI.escape i.to_s } * '='\n        }.compact.sort * '&'\n      end\n    end\n  end\nend","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/alexreisner/geocoder/blob/c10bd701215110ebe65da1c8b8b410b124208fd2/lib/geocoder/lookups/base.rb#L315-L351","documentation":"check_api_key_configuration! raises Geocoder::ConfigurationError before any HTTP request when the number of required API key parts for the lookup exceeds the size of the configured api_key. Multi-part key lookups need every part present.","triggerScenarios":"Using a lookup such as :here that requires an app_id + app_code (or multiple key parts) while only configuring one value in Geocoder.configure(api_key: ...), or leaving api_key nil.","commonSituations":"Services that changed to multi-credential auth (Here, Baidu, Google Premium), copying a single key where the provider issued an ID/secret pair.","solutions":["Configure all required key parts: Geocoder.configure(api_key: [id, code])","Check the lookup's required_api_key_parts to see how many values are needed","Sign up at the provider to obtain the missing credential","Switch to a lookup whose auth model matches the key you have"],"exampleFix":"// before\nGeocoder.configure(lookup: :here, api_key: 'only_app_id')\n// after\nGeocoder.configure(lookup: :here, api_key: ['my_app_id', 'my_app_code'])","handlingStrategy":"validation","validationCode":"required = Geocoder::Lookup.get(:here).required_api_key_parts\nraise 'missing key parts' if required.size > Array(Geocoder.configuration.api_key).size","typeGuard":null,"tryCatchPattern":"begin\n  Geocoder.search(q)\nrescue Geocoder::ConfigurationError => e\n  raise \"Geocoder API key misconfigured: #{e.message}\"\nend","preventionTips":["Configure multi-part keys as arrays matching required_api_key_parts","Check each lookup's docs for its auth requirements","Fail fast with a boot-time key configuration check"],"tags":["ruby","api-key","configuration"],"backgroundTag":"missing-api-key","analyzedSha":"c10bd701215110ebe65da1c8b8b410b124208fd2","analyzedAt":"2026-09-15T23:43:32.125Z","contentChangedAt":"2026-09-15T23:43:32.125Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}