Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions v2/client/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1361,12 +1361,12 @@ var _ = Describe("ConnectionController", func() {
mockServer *httptest.Server
//mockToken string
mockRequest InvokeConnectionRequest
mockResponse map[string]interface{}
//mockResponse map[string]interface{}
)

BeforeEach(func() {
//mockToken = "mock-valid-token"
mockResponse = map[string]interface{}{"key": "value"}
//mockResponse = map[string]interface{}{"key": "value"}
mockRequest = InvokeConnectionRequest{
Headers: map[string]string{
"Content-Type": "application/json",
Expand Down Expand Up @@ -1405,7 +1405,7 @@ var _ = Describe("ConnectionController", func() {
service, err := client.Connection("failed")
response, err := service.Invoke(ctx, mockRequest)
Expect(err).To(BeNil())
Expect(response.Data).To(Equal(mockResponse))
Expect(response.Data).To(Equal(fmt.Sprintf("%v", `{"key": "value"}`)))
})
})
Context("Handling query parameters", func() {
Expand Down
9 changes: 6 additions & 3 deletions v2/internal/validation/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,12 @@ func ValidateInvokeConnectionRequest(request common.InvokeConnectionRequest) *sk
}
// Validate body
if request.Body != nil {
if len(request.Body) == 0 {
logger.Error(fmt.Sprintf(logs.EMPTY_REQUEST_BODY, constants.REQUEST_INVOKE_CONNECTION))
return skyflowError.NewSkyflowError(skyflowError.INVALID_INPUT_CODE, skyflowError.EMPTY_REQUEST_BODY)
// Check if body is a map and if it's empty
if bodyMap, ok := request.Body.(map[string]interface{}); ok {
if len(bodyMap) == 0 {
logger.Error(fmt.Sprintf(logs.EMPTY_REQUEST_BODY, constants.REQUEST_INVOKE_CONNECTION))
return skyflowError.NewSkyflowError(skyflowError.INVALID_INPUT_CODE, skyflowError.EMPTY_REQUEST_BODY)
}
}
}
if request.Method != "" {
Expand Down
Loading
Loading