Invalid JSON body in LoadBalancer create requests using defaults
andrewsomething opened this issue · 2 comments
andrewsomething commented
As originally reported in a comment to #140, attempting to create a load balancer without explicitly setting the boolean values for enable_proxy_protocol
and redirect_http_to_https
will result in an invalid JSON body. Both attributes are set to null
by default resulting in a 500 response from the API.
Script to reproduce:
#!/usr/bin/env ruby
require 'droplet_kit'
require 'json'
token = ENV['DO_TOKEN']
client = DropletKit::Client.new(access_token: token)
load_balancer = DropletKit::LoadBalancer.new(
name: 'example-lb-03',
# enable_proxy_protocol: false,
# redirect_http_to_https: false,
algorithm: 'round_robin',
tag: 'web',
region: 'nyc3',
forwarding_rules: [
DropletKit::ForwardingRule.new(
entry_protocol: 'http',
entry_port: 80,
target_protocol: 'http',
target_port: 80,
certificate_id: '',
tls_passthrough: false
),
DropletKit::ForwardingRule.new(
entry_protocol: 'https',
entry_port: 444,
target_protocol: 'https',
target_port: 443,
certificate_id: '',
tls_passthrough: true
)
],
sticky_sessions: DropletKit::StickySession.new(
type: 'cookies',
cookie_name: 'DO-LB',
cookie_ttl_seconds: 5
),
health_check: DropletKit::HealthCheck.new(
protocol: 'http',
port: 80,
path: '/',
check_interval_seconds: 10,
response_timeout_seconds: 5,
healthy_threshold: 5,
unhealthy_threshold: 3
)
)
puts load_balancer.to_json
client.load_balancers.create(load_balancer)
jonnyarnold commented
Hi @andrewsomething - just following on from your message in #140, adding enable_proxy_protocol: false
fixes my issue!
andrewsomething commented
Great! Thanks for following up @jonnyarnold