Skip to content

fix: serialize whole-object request bodies and accept host_config - #23

Merged
mokevnin merged 1 commit into
mainfrom
fix/request-body-params
Sep 27, 2026
Merged

mokevnin merged 1 commit into
mainfrom
fix/request-body-params

Conversation

@mokevnin

Copy link
Copy Markdown
Member

Ten methods take their request body as one object, but their params models never declared that field, so the SDK sent it as given, in snake_case:

method field
containers.create config
configs.create, configs.update spec
secrets.create, secrets.update spec
services.create, services.update spec
nodes.update, swarm.update spec
volumes.create create_request
client.containers.create(config: {image: "alpine", exposed_ports: {"80/tcp" => {}}})
# before: {"image":"alpine","exposed_ports":{"80/tcp":{}}}
# after:  {"Image":"alpine","ExposedPorts":{"80/tcp":{}}}

Go decodes JSON field names case-insensitively, so image and cmd happened to work, but every multi-word field (exposed_ports, cpu_shares, …) was silently dropped by Docker.

  • Params models: each declares its body field with the model the resource signature already named, so the field is dumped in API names (lib, rbi, rbs).
  • containers.create: also takes host_config:, typed with the existing Container::HostConfig. In the Engine API the create body is ContainerConfig plus HostConfig and NetworkingConfig in one object; host_config is merged in as HostConfig. NetworkingConfig has no model in the SDK and is left out.
  • Tests: cover the request body of containers.create and secrets.create; both fail before the change.

rake lint (rubocop, Sorbet, Steep) and rake test (184 runs, 0 failures) pass.

🤖 Generated with Claude Code

Ten methods take their body as one object (containers.create config, the
spec of configs, secrets, services, nodes and swarm, volumes.create), but
their params models never declared that field. The SDK then sent it as
given, in snake_case: containers.create posted exposed_ports instead of
ExposedPorts, and Docker silently dropped every such field.

The params models now declare the body field with its model, so it is
dumped in API names. containers.create also takes host_config, which the
Engine API expects in the same body as HostConfig, so callers no longer
need extra_body for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mokevnin
mokevnin merged commit d79aa12 into main Sep 27, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant