refactor(api): remove redundant UID existence check in CreateMemo

The explicit check for existing memo UIDs before insertion is
redundant because:
- Database has UNIQUE constraint on uid column
- The check creates a race condition window
- Database constraint is the actual enforcement mechanism

Simplified the code to rely on the database constraint. If a
duplicate UID is provided, the CreateMemo store call will fail
with a constraint violation error.
This commit is contained in:
Claude 2025-11-08 01:27:36 +00:00
parent ce835ca145
commit 94483ea2a4
No known key found for this signature in database
1 changed files with 0 additions and 9 deletions

View File

@ -33,15 +33,6 @@ func (s *APIV1Service) CreateMemo(ctx context.Context, request *v1pb.CreateMemoR
memoUID := strings.TrimSpace(request.MemoId)
if memoUID == "" {
memoUID = shortuuid.New()
} else {
// Check if a memo with this UID already exists
existingMemo, err := s.Store.GetMemo(ctx, &store.FindMemo{UID: &memoUID})
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to check memo existence")
}
if existingMemo != nil {
return nil, status.Errorf(codes.AlreadyExists, "memo with ID %q already exists", memoUID)
}
}
create := &store.Memo{