From 9610ed8fc809b3e7aa4b93e4909634957fa94cf7 Mon Sep 17 00:00:00 2001 From: memoclaw Date: Sun, 29 Mar 2026 20:31:09 +0800 Subject: [PATCH] fix(lint): correct goimports struct literal alignment after removing write-only credential fields (#5794) Co-authored-by: Claude --- server/router/api/v1/idp_service.go | 3 +-- server/router/api/v1/instance_service.go | 10 ++++++---- server/router/api/v1/memo_service.go | 4 ++-- server/router/api/v1/sse_service_test.go | 14 -------------- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/server/router/api/v1/idp_service.go b/server/router/api/v1/idp_service.go index 52535733e..e1db1191f 100644 --- a/server/router/api/v1/idp_service.go +++ b/server/router/api/v1/idp_service.go @@ -185,7 +185,7 @@ func convertIdentityProviderFromStore(identityProvider *storepb.IdentityProvider AuthUrl: oauth2Config.AuthUrl, TokenUrl: oauth2Config.TokenUrl, UserInfoUrl: oauth2Config.UserInfoUrl, - Scopes: oauth2Config.Scopes, + Scopes: oauth2Config.Scopes, FieldMapping: &v1pb.FieldMapping{ Identifier: oauth2Config.FieldMapping.Identifier, DisplayName: oauth2Config.FieldMapping.DisplayName, @@ -233,4 +233,3 @@ func convertIdentityProviderConfigToStore(identityProviderType v1pb.IdentityProv } return nil } - diff --git a/server/router/api/v1/instance_service.go b/server/router/api/v1/instance_service.go index 76166a5ba..4be6986b7 100644 --- a/server/router/api/v1/instance_service.go +++ b/server/router/api/v1/instance_service.go @@ -127,6 +127,8 @@ func (s *APIV1Service) UpdateInstanceSetting(ctx context.Context, request *v1pb. storage.S3Config.AccessKeySecret = existing.S3Config.AccessKeySecret } } + default: + // No credential preservation needed for other setting types. } instanceSetting, err := s.Store.UpsertInstanceSetting(ctx, updateSetting) @@ -261,11 +263,11 @@ func convertInstanceStorageSettingFromStore(settingpb *storepb.InstanceStorageSe } if settingpb.S3Config != nil { setting.S3Config = &v1pb.InstanceSetting_StorageSetting_S3Config{ - AccessKeyId: settingpb.S3Config.AccessKeyId, + AccessKeyId: settingpb.S3Config.AccessKeyId, // AccessKeySecret is write-only: never returned in responses. - Endpoint: settingpb.S3Config.Endpoint, - Region: settingpb.S3Config.Region, - Bucket: settingpb.S3Config.Bucket, + Endpoint: settingpb.S3Config.Endpoint, + Region: settingpb.S3Config.Region, + Bucket: settingpb.S3Config.Bucket, UsePathStyle: settingpb.S3Config.UsePathStyle, } } diff --git a/server/router/api/v1/memo_service.go b/server/router/api/v1/memo_service.go index 6897c1ace..31016ae1e 100644 --- a/server/router/api/v1/memo_service.go +++ b/server/router/api/v1/memo_service.go @@ -28,8 +28,8 @@ func withSuppressSSE(ctx context.Context) context.Context { } func isSSESuppressed(ctx context.Context) bool { - v, _ := ctx.Value(suppressSSEKey{}).(bool) - return v + v, ok := ctx.Value(suppressSSEKey{}).(bool) + return ok && v } func (s *APIV1Service) CreateMemo(ctx context.Context, request *v1pb.CreateMemoRequest) (*v1pb.Memo, error) { diff --git a/server/router/api/v1/sse_service_test.go b/server/router/api/v1/sse_service_test.go index 93c4831dc..180b2aec6 100644 --- a/server/router/api/v1/sse_service_test.go +++ b/server/router/api/v1/sse_service_test.go @@ -32,20 +32,6 @@ func userCtx(ctx context.Context, userID int32) context.Context { return context.WithValue(ctx, auth.UserIDContextKey, userID) } -// drainEvents reads all events currently buffered in the channel and returns -// them as a string slice. It stops as soon as the channel is empty (non-blocking). -func drainEvents(ch <-chan []byte) []string { - var out []string - for { - select { - case data := <-ch: - out = append(out, string(data)) - default: - return out - } - } -} - // collectEventsFor reads events from ch for the given duration and returns them. func collectEventsFor(ch <-chan []byte, d time.Duration) []string { var out []string