From 3704bb5be3af7d2aa2ae3e82002df942d944bf86 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 22 Jul 2020 09:24:42 +0200 Subject: [PATCH] add defensive code on type assertion --- pkg/service/v0/service.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/service/v0/service.go b/pkg/service/v0/service.go index b5d56853a..336537a65 100644 --- a/pkg/service/v0/service.go +++ b/pkg/service/v0/service.go @@ -115,14 +115,15 @@ func getFailsafeIdentifier(c context.Context, identifier *proto.Identifier) *pro identifier = &proto.Identifier{} } if identifier.AccountUuid == "me" { - ownAccountUUID := c.Value(middleware.UUIDKey).(string) - if len(ownAccountUUID) > 0 { - identifier.AccountUuid = ownAccountUUID - } else { - // might be valid for the request not having an AccountUuid in the identifier. - // but clear it, instead of passing on `me`. - identifier.AccountUuid = "" + ownAccountUUID, ok := c.Value(middleware.UUIDKey).(string) + if ok { + if len(ownAccountUUID) > 0 { + identifier.AccountUuid = ownAccountUUID + } } + // might be valid for the request not having an AccountUuid in the identifier. + // but clear it, instead of passing on `me`. + identifier.AccountUuid = "" } identifier.AccountUuid = strings.ToLower(identifier.AccountUuid) return identifier