fix(email-connectors): return profile-import error early in KlaviyoAdapter.upsertSubscriber

Đang mở Phù hợp với người mới
#64 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

Đọc packages/email-connectors/src/adapters/klaviyo.adapter.ts, đặc biệt là KlaviyoAdapter.upsertSubscriber quanh các dòng 107-136. Theo dõi cách phản hồi từ /profile-import/ được xử lý trước yêu cầu tùy chọn về mối quan hệ với danh sách. Kết quả cần đạt là khi nhập hồ sơ thất bại, lỗi được trả về ngay mà không gửi yêu cầu danh sách; còn khi nhập thành công, hành vi hiện tại được giữ nguyên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

backend good first issue
Problem Description

In packages/email-connectors/src/adapters/klaviyo.adapter.ts (upsertSubscriber, lines 86-136), when POST /profile-import/ fails (!profileRes.ok), profileId remains undefined. When listId is provided, the method still proceeds to call POST /lists/${listId}/relationships/profiles/ with id: undefined, which fails and masks the original /profile-import/ error behind "Failed to add to Klaviyo list: ...".


Expected Behavior
  • If POST /profile-import/ returns a non-OK response (!profileRes.ok), upsertSubscriber should immediately return { success: false, error: 'Failed to create Klaviyo profile: ...' } without making a wasted second request.
  • When POST /profile-import/ succeeds (profileRes.ok), behavior remains unchanged.

Where to Look
  • packages/email-connectors/src/adapters/klaviyo.adapter.ts (upsertSubscriber, lines 107-136)

Solution / Implementation Guide
  1. Right after const profileRes = await fetch(...), check if (!profileRes.ok) first:
    if (!profileRes.ok) {
      const errText = await profileRes.text();
      return { success: false, error: `Failed to create Klaviyo profile: ${errText}` };
    }
    
  2. Parse profileId = profileJson?.data?.id, and only proceed to POST /lists/${listId}/relationships/profiles/ when listId is provided and profileRes.ok succeeded.
Ngôn ngữ chính
TypeScript
Star
2
Fork
1
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sumamakhan761/tryinstance

Tất cả issue của sumamakhan761/tryinstance

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.