hcloud-ruby
hcloud-ruby copied to clipboard
1.2.0 release raises `undefined method 'blank?'` errors
Hi, I updated from 1.1.0 to 1.2.0 and I cannot create ssh keys anymore. It aborts with this error:
undefined method `blank?' for "Beaker-runner-fv-az186-249-4769264692-2023-11-01_09_28_37_305488169":String
/home/runner/work/puppet-systemd/puppet-systemd/vendor/bundle/ruby/3.2.0/gems/hcloud-1.2.0/lib/hcloud/ssh_key_resource.rb:15:in `create'
/home/runner/work/puppet-systemd/puppet-systemd/vendor/bundle/ruby/3.2.0/bundler/gems/beaker-hcloud-5afc510af942/lib/beaker/hypervisor/hcloud.rb:67:in `create_ssh_key'
/home/runner/work/puppet-systemd/puppet-systemd/vendor/bundle/ruby/3.2.0/bundler/gems/beaker-hcloud-5afc510af942/lib/beaker/hypervisor/hcloud.rb:29:in `provision'
I noticed that between the 1.1.0 and 1.2.0 release a bunch of validation got added that checks strings with .blank?
. That's not a Ruby method for the String class but a Rails method. I assume the dependency is missing.
Steps to reproduce:
require 'hcloud'
# https://github.com/bastelfreak/beaker-hcloud/blob/label2/lib/beaker-hcloud/ssh_data_patches.rb
require_relative 'lib/beaker-hcloud/ssh_data_patches'
client = ::Hcloud::Client.new(token: token)
ssh_key_name = 'foo1234'
ssh_key = SSHData::PrivateKey::ED25519.generate
key_file = Tempfile.create(ssh_key_name)
File.write(key_file.path, ssh_key.openssh(comment: ssh_key_name))
hcloud_ssh_key = client.ssh_keys.create(name: ssh_key_name, public_key: ssh_key.public_key.openssh(comment: ssh_key_name))
This gives me:
NoMethodError: undefined method `blank?' for "foo123":String
```
After some digging around I noticed that activemodel has no version constraints which is quite bad. In 6.x `.blank?` is available, but not in 7 (or it got moved and we need to require something else, but I've no time to dig into this right now).