diff --git a/sdk/plugin/grpc_storage.go b/sdk/plugin/grpc_storage.go index 3da2ce312..b7fd0caf8 100644 --- a/sdk/plugin/grpc_storage.go +++ b/sdk/plugin/grpc_storage.go @@ -90,6 +90,12 @@ func (s *GRPCStorageServer) List(ctx context.Context, args *pb.StorageListArgs) func (s *GRPCStorageServer) Get(ctx context.Context, args *pb.StorageGetArgs) (*pb.StorageGetReply, error) { storageEntry, err := s.impl.Get(ctx, args.Key) + if storageEntry == nil { + return &pb.StorageGetReply{ + Entry: nil, + Err: pb.ErrToString(err), + }, nil + } return &pb.StorageGetReply{ Entry: pb.LogicalStorageEntryToProtoStorageEntry(storageEntry), Err: pb.ErrToString(err), diff --git a/vault/ui.go b/vault/ui.go index bd1d3c688..feb90f309 100644 --- a/vault/ui.go +++ b/vault/ui.go @@ -158,37 +158,30 @@ func (c *UIConfig) get(ctx context.Context) (*uiConfigEntry, error) { if err != nil { return nil, err } + configRaw, uiConfigGetErr := c.barrierStorage.Get(ctx, uiConfigKey) - configRaw, err := c.barrierStorage.Get(ctx, uiConfigKey) - if err == nil { - if configRaw == nil { - return nil, nil - } - config := new(uiConfigEntry) - if err := json.Unmarshal(configRaw.Value, config); err != nil { - return nil, err - } + // Respond with error only if not sealed, otherwise do not throw the error + if uiConfigGetErr != nil && !strings.Contains(uiConfigGetErr.Error(), ErrBarrierSealed.Error()) { + return nil, uiConfigGetErr + } + if configRaw == nil { + return nil, nil + } + + config := new(uiConfigEntry) + if config == nil { + return nil, nil + } + if err := json.Unmarshal(configRaw.Value, config); err != nil { + return nil, err + } + if uiConfigGetErr == nil { // Check that plaintext value matches barrier value, if not sync values if plaintextConfigRaw == nil || bytes.Compare(plaintextConfigRaw.Value, configRaw.Value) != 0 { if err := c.save(ctx, config); err != nil { return nil, err } } - return config, nil - } - - // Respond with error if not sealed - if !strings.Contains(err.Error(), ErrBarrierSealed.Error()) { - return nil, err - } - - // Respond with plaintext value - if configRaw == nil { - return nil, nil - } - config := new(uiConfigEntry) - if err := json.Unmarshal(plaintextConfigRaw.Value, config); err != nil { - return nil, err } return config, nil }