gitlabhq/gitlabhq · error · RemoteMirrors::HostKeysConverter::InvalidHostKeyError
cannot determine hostname from URL for bare key
Error message
cannot determine hostname from URL for bare key
What it means
Error "cannot determine hostname from URL for bare key" thrown in gitlabhq/gitlabhq.
Source
Thrown at app/models/remote_mirrors/host_keys_converter.rb:102
def sanitize_key(key)
parts = Gitlab::SSHPublicKey.extract_key_parts(key)
return key unless parts
[parts[:prefix].presence, parts[:algorithm], restore_base64_encoding(parts[:key_data])].compact.join(' ')
end
# Form-encoded params (application/x-www-form-urlencoded) decode '+' as spaces.
# SSH key base64 data uses '+' characters, so we restore them here.
def restore_base64_encoding(key_data)
key_data.tr(' ', '+')
end
def normalize_key(key)
return if key.blank?
return key if key.match?(KEY_WITH_HOSTNAME_REGEX)
raise InvalidHostKeyError, ["cannot determine hostname from URL for bare key"] if known_hosts_hostname.blank?
"#{known_hosts_hostname} #{key}"
end
def known_hosts_hostname
return if url.blank?
uri = Addressable::URI.parse(url)
host = uri.host
return if host.blank?
port = uri.port
return host if port.nil? || port == STANDARD_SSH_PORT
"[#{host}]:#{port}"
rescue Addressable::URI::InvalidURIError
nil
endView on GitHub (pinned to 55ee20384a)
When it happens
Trigger: Thrown at app/models/remote_mirrors/host_keys_converter.rb:102 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of gitlabhq/gitlabhq@55ee20384a (2026-08-21).
Data as JSON: /api/errors/31a7fff8f19712b7.
Report an issue: GitHub.