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

Pop up an error when invoking (POST) application method with an empty payload #121

Closed
v-mengwe opened this issue Sep 3, 2020 · 2 comments · Fixed by #123
Closed

Pop up an error when invoking (POST) application method with an empty payload #121

v-mengwe opened this issue Sep 3, 2020 · 2 comments · Fixed by #123
Assignees
Labels
AT-CTI Issues found by internal test team bug Something isn't working
Milestone

Comments

@v-mengwe
Copy link

v-mengwe commented Sep 3, 2020

OS: All
Build Version: 20200902.2

Repro Steps:

  1. Create a new .NET Web API application by "dotnet new webapi --no-https --name netwebapp".
  2. Open the application in VS Code --> Select "Dapr: Scaffold Dapr Tasks" from Command Palette --> Select ".NET Core Launch (web)" when asked to select a configuration --> Enter an application ID --> Enter an application port.
  3. Add the following within the class definition:
[HttpPost]
	public ActionResult Post([FromBody] object body)
	{
              return new JsonResult(body);
        }
  1. Debug with ".NET Core Launch (web) with Dapr".
  2. Right click the running application --> Select "Invoke (POST) Application Method" --> Enter "WeatherForecast" --> Enter an empty payload.
  3. Check the result.

Expect:
The method was invoked and succeeded.

Actual:
Pop up an error.
image

More Info:

  1. This issue also reproduces for node.js project.
  2. This issue doesn't reproduce when publishing message to application with an empty payload.
@v-mengwe v-mengwe added the AT-CTI Issues found by internal test team label Sep 3, 2020
@philliphoff philliphoff self-assigned this Sep 3, 2020
@philliphoff philliphoff added the bug Something isn't working label Sep 3, 2020
@philliphoff philliphoff added this to the 0.3.0 milestone Sep 3, 2020
@philliphoff
Copy link
Member

It looks like we're not handling empty payloads properly in the case of post/publish, though it happens to work for publish. I'll create a PR for a fix. Note, however, that you might still get an error response from the server (400 or 415) if the server expects a valid (i.e. non-null) payload (which ASP.NET does, when using the [FromBody] attribute.

@v-mengwe
Copy link
Author

v-mengwe commented Sep 4, 2020

Got it, thanks for your sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AT-CTI Issues found by internal test team bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants