Skip to content

Commit 52655ee

Browse files
API ported - fix to return null in exact same format as python
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent ffb2092 commit 52655ee

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

cla-backend-go/swagger/cla.v2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,7 @@ paths:
24622462
'project_id': <project-id>,
24632463
'repository_id': <repository-id>,
24642464
'pull_request_id': <PR>,
2465+
*'merge_request_id': <MR> (optional),
24652466
'return_url': <url-where-user-initiated-signature-from>'
24662467
}
24672468
Returns null if the user does not have an active signature.

cla-backend-go/v2/sign/handlers.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"github.com/linuxfoundation/easycla/cla-backend-go/gen/v2/restapi/operations/sign"
2525
"github.com/linuxfoundation/easycla/cla-backend-go/utils"
2626
"github.com/linuxfoundation/easycla/cla-backend-go/v2/organization-service/client/organizations"
27+
28+
"github.com/go-openapi/runtime"
2729
)
2830

2931
var (
@@ -265,6 +267,13 @@ func Configure(api *operations.EasyclaAPI, service Service, userService users.Se
265267
if err != nil {
266268
return sign.NewGetUserActiveSignatureBadRequest().WithPayload(errorResponse(reqId, err))
267269
}
270+
if resp == nil {
271+
return middleware.ResponderFunc(func(w http.ResponseWriter, _ runtime.Producer) {
272+
w.Header().Set("Content-Type", "application/json")
273+
w.WriteHeader(http.StatusOK)
274+
_, _ = w.Write([]byte("null"))
275+
})
276+
}
268277
return sign.NewGetUserActiveSignatureOK().WithPayload(resp)
269278
})
270279

cla-backend-go/v2/sign/service.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,9 @@ func (s *service) GetUserActiveSignature(ctx context.Context, userID string) (*m
28522852
log.WithFields(f).WithError(err).Warnf("unable to get active signature meta data for user: %s", userID)
28532853
return nil, err
28542854
}
2855+
if len(activeSignatureMetadata) == 0 {
2856+
return nil, nil
2857+
}
28552858
log.WithFields(f).Debugf("active signature metadata: %+v", activeSignatureMetadata)
28562859
var (
28572860
mergeRequestId *string

0 commit comments

Comments
 (0)