Skip to content

Commit 03b33ea

Browse files
Flow API: Add nil check in create CDC request (#3586)
If you send a create mirror request via flow api and you do not wrap your request in `connection_configs`, flow-api will run into a panic. This adds a nil check for this pitfall
1 parent 96f2a31 commit 03b33ea

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

flow/cmd/handler.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ func (h *FlowRequestHandler) CreateCDCFlow(
136136
ctx context.Context, req *protos.CreateCDCFlowRequest,
137137
) (*protos.CreateCDCFlowResponse, APIError) {
138138
cfg := req.ConnectionConfigs
139+
if cfg == nil {
140+
// todo(@iamKunalGupta): add a panic recovery handler with metric and alert for it
141+
return nil, NewInvalidArgumentApiError(errors.New("connection configs cannot be nil"))
142+
}
139143
internalVersion, err := internal.PeerDBForceInternalVersion(ctx, req.ConnectionConfigs.Env)
140144
if err != nil {
141145
return nil, NewInternalApiError(fmt.Errorf("failed to get internal version: %w", err))

0 commit comments

Comments
 (0)