Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk/client: req marshal with []byte instead of *[]byte #611

Merged
merged 3 commits into from
Aug 14, 2023

Conversation

wuxu92
Copy link
Contributor

@wuxu92 wuxu92 commented Aug 10, 2023

The argument for request marshal is []byte not '*[]byte (the response is *[]byte)

so method below would failed with err: performing ReplaceContent: internal-error: payload must be *[]byte but got [xx xx]

func (c RunbookDraftClient) ReplaceContent(ctx context.Context, id RunbookId, input []byte) (result ReplaceContentOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "text/powershell",
ExpectedStatusCodes: []int{
http.StatusAccepted,
http.StatusOK,
},
HttpMethod: http.MethodPut,
Path: fmt.Sprintf("%s/draft/content", id.ID()),
}
req, err := c.Client.NewRequest(ctx, opts)
if err != nil {
return
}
if err = req.Marshal(input); err != nil {

@wuxu92 wuxu92 requested a review from a team as a code owner August 10, 2023 09:13
Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @wuxu92, this looks ok to me, I would just make sure to update the error message for clarity.

sdk/client/client.go Outdated Show resolved Hide resolved
@manicminer manicminer added enhancement New feature or request base-layer labels Aug 13, 2023
@manicminer manicminer merged commit 3229ebf into hashicorp:main Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base-layer enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants