Skip to content

Commit a72ef1a

Browse files
authored
[client] Fix error handling for set config request on CLI (#4237)
[client] Fix error handling for set config request on CLI (#4237)
1 parent 980a6ec commit a72ef1a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

client/cmd/up.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
log "github.com/sirupsen/logrus"
1414
"github.com/spf13/cobra"
1515
"google.golang.org/grpc/codes"
16+
1617
gstatus "google.golang.org/grpc/status"
1718
"google.golang.org/protobuf/types/known/durationpb"
1819

@@ -242,7 +243,11 @@ func runInDaemonMode(ctx context.Context, cmd *cobra.Command, pm *profilemanager
242243
// set the new config
243244
req := setupSetConfigReq(customDNSAddressConverted, cmd, activeProf.Name, username.Username)
244245
if _, err := client.SetConfig(ctx, req); err != nil {
245-
return fmt.Errorf("call service set config method: %v", err)
246+
if st, ok := gstatus.FromError(err); ok && st.Code() == codes.Unavailable {
247+
log.Warnf("setConfig method is not available in the daemon")
248+
} else {
249+
return fmt.Errorf("call service setConfig method: %v", err)
250+
}
246251
}
247252

248253
if err := doDaemonUp(ctx, cmd, client, pm, activeProf, customDNSAddressConverted, username.Username); err != nil {

client/server/server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,11 @@ func (s *Server) Login(callerCtx context.Context, msg *proto.LoginRequest) (*pro
452452
}
453453

454454
if *msg.ProfileName != activeProf.Name && username != activeProf.Username {
455+
if s.checkProfilesDisabled() {
456+
log.Errorf("profiles are disabled, you cannot use this feature without profiles enabled")
457+
return nil, gstatus.Errorf(codes.Unavailable, errProfilesDisabled)
458+
}
459+
455460
log.Infof("switching to profile %s for user '%s'", *msg.ProfileName, username)
456461
if err := s.profileManager.SetActiveProfileState(&profilemanager.ActiveProfileState{
457462
Name: *msg.ProfileName,

0 commit comments

Comments
 (0)