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

fix(dash): Init httpRequestSpec's Body properly if rawPayload is not empty #1109

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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.

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