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

500 error is returned when mandatory argument is not provided #192

Open
Alma-media opened this issue May 26, 2021 · 0 comments
Open

500 error is returned when mandatory argument is not provided #192

Alma-media opened this issue May 26, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@Alma-media
Copy link
Member

Alma-media commented May 26, 2021

Describe the bug
Proper error handling is missing

To Reproduce
running the example (functions):

$ go run main.go daemon -f ../../examples/functions/config.hcl 

making the request (missing "name" parameter):

[POST] http//localhost:8080/numeric
{
    "age": 35
}

getting status 500 Internal Server Error and empty response body

Application log:

1622023136544832264	info	listener.http	serving HTTP listener	{"addr": ":8080"}
1622023161881029516	error	flow.numeric	an error occurred, executing rollback	{"error": "value is not set"}
github.com/jexia/semaphore/v2/pkg/broker/logger.Error
	/home/alma/Projects/semaphore/pkg/broker/logger/logger.go:85
github.com/jexia/semaphore/v2/pkg/flow.(*Manager).Do
	/home/alma/Projects/semaphore/pkg/flow/flow.go:154
github.com/jexia/semaphore/v2/pkg/transport/http.(*Handle).HTTPFunc
	/home/alma/Projects/semaphore/pkg/transport/http/listener.go:252
github.com/julienschmidt/httprouter.(*Router).ServeHTTP
	/home/alma/Projects/semaphore/vendor/github.com/julienschmidt/httprouter/router.go:387
github.com/jexia/semaphore/v2/pkg/transport/http.(*Listener).Serve.func1
	/home/alma/Projects/semaphore/pkg/transport/http/listener.go:68
net/http.HandlerFunc.ServeHTTP
	/usr/lib/go/src/net/http/server.go:2069
net/http.serverHandler.ServeHTTP
	/usr/lib/go/src/net/http/server.go:2887
net/http.(*conn).serve
	/usr/lib/go/src/net/http/server.go:1952

Expected
status 400 Bad Request and response body containing:

{
    "error": "value is not set"
}
@Alma-media Alma-media added the bug Something isn't working label May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant