fix!: drop the always-empty return value from Create - #51
Open
tas50 wants to merge 1 commit into
Open
Conversation
This was referenced Sep 8, 2026
Merged
tas50
force-pushed
the
fix-create-returns-response
branch
3 times, most recently
from
September 8, 2026 16:53
b9ebabd to
8a0cb33
Compare
Nodes.Create, Roles.Create and Environments.Create returned a *T decoded
from the POST response. The Chef Server answers those with {"uri":...}, not
the created object, so the value was always a zero-valued struct behind a
non-nil pointer - the repo's own fixture (roles_test.go) returns exactly
that envelope and every caller discarded the result.
Return (*Response, error) instead, matching Delete. Clients.Create keeps its
*APIClient: chef_key really is in that response, and it carries the private
key a caller must capture.
BREAKING CHANGE: callers of Nodes.Create, Roles.Create and
Environments.Create drop one return value.
node, resp, err := c.Nodes.Create(ctx, n) // before
resp, err := c.Nodes.Create(ctx, n) // after
Signed-off-by: Tim Smith <tim@mondoo.com>
tas50
force-pushed
the
fix-create-returns-response
branch
from
September 10, 2026 16:37
8a0cb33 to
b2e1e75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nodes.Create,Roles.CreateandEnvironments.Createreturned a*Tdecoded from the POST response body. The Chef Server answers those endpoints with{"uri":…}, not the created object — so the returned value was always a zero-valued struct behind a non-nil pointer.The repo's own fixture says as much (
roles_test.go:16):and every call site in the repo already discarded the value. Confirmed against cinc-zero too:
Nodes.Createreturns&Node{}with every field empty.The change
Now matches
Delete, which already returns(*Response, error).Clients.Createdeliberately keeps its*APIClient:chef_keygenuinely is in that response, and it carries the generated private key a caller has exactly one chance to capture.Migration
Mechanical — drop one return value at each call site:
Test plan
TestNodesCreate_ReturnsOnlyResponseAndError— asserts the 201 comes back on*Response(did not compile before the change, which is the red for a signature change)nodes_test.go,roles_test.go,environments_test.go,integration/integration_test.gogo vet ./...cleango test ./... -race -count=2cd integration && go test ./...