{"record":{"id":"603c7fbc4ef9923a","repo":"alexreisner/geocoder","slug":"error-parsing-protocol-upcase-proxy-url-proxy-url","errorCode":null,"errorMessage":"Error parsing #{protocol.upcase} proxy URL: '#{proxy_url}'","messagePattern":"Error parsing #(.+?) proxy URL: '#(.+?)'","errorType":"exception","errorClass":"ConfigurationError","httpStatus":null,"severity":"error","filePath":"lib/geocoder/lookups/base.rb","lineNumber":129,"sourceCode":"\n      ##\n      # An object with configuration data for this particular lookup.\n      #\n      def configuration\n        Geocoder.config_for_lookup(handle)\n      end\n\n      ##\n      # Object used to make HTTP requests.\n      #\n      def http_client\n        proxy_name = \"#{protocol}_proxy\"\n        if proxy = configuration.send(proxy_name)\n          proxy_url = !!(proxy =~ /^#{protocol}/) ? proxy : protocol + '://' + proxy\n          begin\n            uri = URI.parse(proxy_url)\n          rescue URI::InvalidURIError\n            raise ConfigurationError,\n              \"Error parsing #{protocol.upcase} proxy URL: '#{proxy_url}'\"\n          end\n          Net::HTTP::Proxy(uri.host, uri.port, uri.user, uri.password)\n        else\n          Net::HTTP\n        end\n      end\n\n      ##\n      # Geocoder::Result object or nil on timeout or other error.\n      #\n      def results(query)\n        fail\n      end\n\n      def query_url_params(query)\n        query.options[:params] || {}\n      end","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/alexreisner/geocoder/blob/c10bd701215110ebe65da1c8b8b410b124208fd2/lib/geocoder/lookups/base.rb#L111-L147","documentation":"Raised by Geocoder::Lookups::Base#http_client when the configured :http_proxy (or :https_proxy) string cannot be parsed as a URI. Geocoder wraps URI::InvalidURIError into a Geocoder::ConfigurationError naming the protocol and the offending URL.","triggerScenarios":"Setting Geocoder.configure(http_proxy: 'not a url') or an https_proxy value with illegal characters (spaces, missing scheme handled by prefixing but still malformed, stray braces), so URI.parse raises URI::InvalidURIError.","commonSituations":"Copy-pasting proxy URLs with quotes, whitespace or credentials containing unencoded special characters; reading the proxy from env vars that are empty or malformed.","solutions":["Fix the proxy URL so it is a valid URI, e.g. 'http://user:pass@host:port'","URL-encode special characters in proxy credentials (URI.encode_www_form_component)","Verify environment variables (HTTP_PROXY etc.) feeding the config are well-formed","Test with URI.parse(proxy_url) in a console before configuring"],"exampleFix":"// before\nGeocoder.configure(http_proxy: 'proxy mycorp com:3128')\n// after\nGeocoder.configure(http_proxy: 'http://proxy.mycorp.com:3128')","handlingStrategy":"validation","validationCode":"URI.parse(proxy_url) # call before configuring; rescue URI::InvalidURIError","typeGuard":"def valid_proxy?(url); !!(URI.parse(url =~ %r{^https?://} ? url : \"http://#{url}\")); rescue URI::InvalidURIError; false; end","tryCatchPattern":"begin\n  Geocoder.search(q)\nrescue Geocoder::ConfigurationError => e\n  raise if e.message !~ /proxy/i\n  Geocoder.configure(http_proxy: ENV.fetch('HTTP_PROXY'))\nend","preventionTips":["Store fully-formed proxy URLs (scheme://host:port)","URL-encode usernames/passwords in proxy URLs","Validate env-derived proxy values at boot"],"tags":["ruby","proxy","configuration","url"],"backgroundTag":"invalid-url-format","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"}