Skip to content

Conversation

@Akos-T
Copy link
Contributor

@Akos-T Akos-T commented Mar 27, 2024

Problem

  1. Given a POST API with body payload, e.g:
//encore:api public method=POST path=/hello/:name
func World(ctx context.Context, name string, params *RequestType) (*Response, error) {
   // ... 
}

type RequestType struct {
	AlternativeName *string `json:"alternativeName,omitempty" encore:"optional"` // Some description for AlternativeName
	Mambo           string  `json:"mambo,omitempty"`                             // Some description for Mambo
}
  1. On the local dashboard when we try this endpoint, leave the body empty:
{ }
  1. Getting error:
HTTP 400 Bad Request: { "code": "invalid_argument", "message": "decode request: request_body: missing request body: missing request body", "details": null }
Screenshot 2024-03-27 at 10 17 24

Cause

In cli/daemon/dash/dash.go, addToRequest function we initialize the Body field on the *httpRequestSpec type only if there's content in the processed (hujson) payload, otherwise nil.

Solution

Initialize properly the Body field on the *httpRequestSpec type when the rawPayload is not empty

@encore-cla
Copy link

encore-cla bot commented Mar 27, 2024

All committers have signed the CLA.

@marcuskohlberg marcuskohlberg requested a review from eandre April 3, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant