Skip to content

[Refactor/#521] 전체 이미지 presigned 업로드 계약 동기화 - #523

Merged
move-hoon merged 5 commits into
developfrom
refactor/#521/CarouselPresigned
Jul 27, 2026
Merged

move-hoon merged 5 commits into
developfrom
refactor/#521/CarouselPresigned

Conversation

@move-hoon

@move-hoon move-hoon commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

📌 관련 이슈번호

🎟️ PR 유형

  • 새 기능 추가
  • 버그 수정
  • CSS 등 사용자 UI 디자인 변경
  • 리팩토링

✅ Key Changes

  1. 공연 등록·수정의 포스터, 출연진, 스태프, 상세 이미지가 uploadUrl과 imageKey 계약을 사용합니다.
  2. S3 PUT에는 서명된 uploadUrl 원문을 사용하고 mutateAsync로 완료를 기다립니다.
  3. 저장 요청에는 URL이 아닌 서버 발급 imageKey를 전달합니다.
  4. 응답 Map 순서 대신 요청 파일명으로 업로드 정보를 찾습니다.
  5. 공연 수정에서는 기존 CDN 이미지를 유지하고 신규 로컬 이미지만 업로드합니다.
  6. 관리자 캐러셀도 같은 계약을 사용하며 사용되지 않는 /api/image/upload 클라이언트 코드를 제거했습니다.

🧪 검증

  • yarn prettier --check src/apis/domains/files/api.ts src/pages/register/Register.tsx src/pages/modifyManage/ModifyManage.tsx src/typings/api/schema/index.ts
  • yarn tsc -b
  • 변경 파일 직접 ESLint: 오류 0건, 기존 console 경고 5건
  • 공용 검증 스크립트의 전체 테스트는 기존 generatePerformanceRoute.test.ts 기대 경로 /gig/7 불일치 2건과 ESLint 9에서 제거된 --ext 옵션 때문에 별도로 실패합니다. 이번 변경 파일과 무관합니다.

📢 To Reviewers

  • BEAT-SERVER #564와 함께 배포해야 합니다.
  • 서버의 배너 API는 구조화 응답까지 포함하지만 현재 클라이언트에는 배너 저장 UI 호출부가 없습니다.

📸 스크린샷

  • API 계약 및 업로드 제어 흐름 변경으로 생략합니다.

🔗 참고 자료

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • 개선 사항
    • 프로모션 캐러셀 이미지 저장 및 업로드 흐름이 안정화되었습니다.
    • 새로 추가한 캐러셀 항목이 저장 데이터와 즉시 동기화됩니다.
    • 이미지 등록·수정 시 업로드 결과가 정확히 반영됩니다.
  • 버그 수정
    • 이미지 업로드 정보가 누락되거나 업로드에 실패할 때 명확한 알림이 표시됩니다.
    • 기존 이미지와 새 이미지가 섞인 경우에도 안정적으로 처리됩니다.
    • 캐러셀 신규 항목의 식별자 충돌 가능성을 줄였습니다.

Walkthrough

공연 등록·수정과 관리자 캐러셀의 이미지 업로드가 uploadUrl 직접 사용 및 imageKey 전달 방식으로 변경되었습니다. Presigned 응답 타입이 갱신되었고, 파일명 기반 매핑과 업로드 실패 처리가 적용되었습니다.

Changes

이미지 업로드 계약

Layer / File(s) Summary
Presigned 응답 계약과 API 연결
src/typings/api/schema/index.ts, src/apis/domains/files/api.ts, src/apis/domains/register/index.ts
공연 메이커와 캐러셀 presigned 응답에 업로드 URL·imageKey 구조가 추가되고, 관련 API 반환 타입과 레거시 업로드 훅이 변경 또는 제거되었습니다.

공연 이미지 흐름

Layer / File(s) Summary
공연 등록 이미지 업로드
src/pages/register/Register.tsx
포스터·출연진·스태프·상세 이미지를 파일명 키로 조회하고 업로드 결과의 imageKey를 요청 데이터에 사용합니다.
공연 수정 이미지 업로드
src/pages/modifyManage/ModifyManage.tsx
로컬 이미지를 File로 변환해 업로드하며, 업로드 실패를 알림으로 처리하고 imageKey를 사용합니다.

관리자 캐러셀

Layer / File(s) Summary
관리자 캐러셀 업로드와 저장
src/admin/pages/promotion/Promotion.tsx, src/admin/pages/promotion/components/AdminCarousel/AdminCarousel.tsx
blob 이미지를 pending 목록으로 수집하고 presigned 업로드 후 imageKey로 치환하여 저장하며, 캐러셀 상태 동기화와 신규 ID 생성 방식도 변경되었습니다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RegisterPage
  participant PresignedAPI
  participant S3Uploader
  participant BackendAPI
  RegisterPage->>PresignedAPI: 파일명별 업로드 정보 요청
  PresignedAPI-->>RegisterPage: uploadUrl과 imageKey 반환
  RegisterPage->>S3Uploader: 파일과 uploadUrl 전달
  S3Uploader-->>RegisterPage: 업로드 완료
  RegisterPage->>BackendAPI: imageKey 기반 등록·수정 요청
Loading

Possibly related issues

  • TEAM-BEAT/BEAT-SERVER 563: 공연 및 캐러셀 이미지에 uploadUrl과 imageKey를 적용하는 서버 계약과 직접 연결됩니다.

Possibly related PRs

  • TEAM-BEAT/BEAT-Client#520: 공연 등록의 presigned 업로드 결과 매핑과 요청 데이터 주입 흐름이 직접적으로 관련됩니다.

Suggested reviewers: imddoy, ocahs9, pepperdad

Poem

토끼가 uploadUrl을 타고
당근 대신 imageKey를 물어요.
캐러셀도 폴짝, 공연도 폴짝,
실패 알림은 딱 한 번!
S3 숲에 새 이미지가 피었답니다. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning 배너 presigned 응답 타입 추가는 링크된 #521의 등록·수정·캐러셀·레거시 제거 범위를 벗어납니다. 배너 계약이 이번 범위라면 이슈에 명시하고, 아니면 해당 스키마 추가를 별도 작업으로 분리하거나 제거하세요.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 주요 변경인 이미지 presigned 업로드 계약 동기화를 간결하게 잘 요약합니다.
Description check ✅ Passed 필수 섹션인 이슈, 유형, 변경점, 리뷰어, 스크린샷, 참고자료가 대부분 충실히 작성되었습니다.
Linked Issues check ✅ Passed 등록·수정 이미지, 관리자 캐러셀, 레거시 클라이언트 제거, imageKey 전달, 파일명 매핑 요구를 충족합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#521/CarouselPresigned

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

PR 작성하느라 고생 많았어요!! 라벨 잘 지정되었는지 확인 한 번 해 주기 🫶

@github-actions github-actions Bot added ♻️ REFACTOR 프로덕션 코드 리팩토링 🚀 API API labels Jul 27, 2026
@move-hoon
move-hoon requested review from imddoy and sinji2102 July 27, 2026 13:45
@move-hoon move-hoon removed the 🚀 API API label Jul 27, 2026
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

@move-hoon
move-hoon marked this pull request as ready for review July 27, 2026 13:58
@github-actions
github-actions Bot requested review from ocahs9 and pepperdad July 27, 2026 13:58
@move-hoon move-hoon changed the title [Refactor/#521] 캐러셀 presigned 업로드 계약 동기화 [Refactor/#521] 전체 이미지 presigned 업로드 계약 동기화 Jul 27, 2026
@github-actions

Copy link
Copy Markdown

@sinji2102 sinji2102 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정사항만 확인해 주면 머지해도 될 것 같아용
굿굿

Comment thread src/pages/modifyManage/ModifyManage.tsx Resolved
Co-authored-by: Sinji Yun <66528589+sinji2102@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/apis/domains/files/api.ts (1)

138-140: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

의미 없는 try/catch입니다.

catch (error) { throw error; }는 아무 동작도 하지 않으므로 no-useless-catch 대상입니다. try 블록을 제거하는 편이 깔끔합니다.

♻️ 제안 리팩토링
-    return response.data;
-  } catch (error) {
-    throw error;
-  }
-};
+    return response.data;
+};

(try 블록 시작부의 try {도 함께 제거하고 들여쓰기를 정리해 주세요.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/apis/domains/files/api.ts` around lines 138 - 140, Remove the redundant
try/catch surrounding the affected logic in the file API handler, including the
try opening and catch block, then normalize indentation while preserving the
existing statements and error propagation behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/admin/pages/promotion/components/AdminCarousel/AdminCarousel.tsx`:
- Around line 30-34: Update the saveCarouselNum call in AdminCarousel so the
optional promotionList is defaulted to an empty array before invoking map.
Preserve the existing promotionId extraction and ensure both missing data and
missing promotionList produce [] without throwing.

In `@src/admin/pages/promotion/Promotion.tsx`:
- Around line 117-136: Handle the empty formData.carousels case in the save flow
so deleting all carousels produces an explicit outcome. Update the condition
around updateCarousel and validation to either allow saving the empty list and
show the existing completion alert, or show a clear minimum-one-carousel alert;
ensure the empty list does not fall through to a no-op forEach.

In `@src/apis/domains/files/api.ts`:
- Around line 9-25: Update the ImagePresignedUpload interface so uploadUrl and
imageKey are optional, matching the generated schema contract. Then update each
call site using ImagePresignedUpload to validate both values before initiating
the S3 PUT, including cases where the upload object exists but either field is
missing.

---

Nitpick comments:
In `@src/apis/domains/files/api.ts`:
- Around line 138-140: Remove the redundant try/catch surrounding the affected
logic in the file API handler, including the try opening and catch block, then
normalize indentation while preserving the existing statements and error
propagation behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b6da118-ddf2-4c8e-8c1b-d7ec7918b679

📥 Commits

Reviewing files that changed from the base of the PR and between f109511 and e5a236b.

📒 Files selected for processing (7)
  • src/admin/pages/promotion/Promotion.tsx
  • src/admin/pages/promotion/components/AdminCarousel/AdminCarousel.tsx
  • src/apis/domains/files/api.ts
  • src/apis/domains/register/index.ts
  • src/pages/modifyManage/ModifyManage.tsx
  • src/pages/register/Register.tsx
  • src/typings/api/schema/index.ts
💤 Files with no reviewable changes (1)
  • src/apis/domains/register/index.ts

Comment on lines 30 to 34
saveCarouselNum(
data?.promotionList.map((item) => {
return item.promotionId;
})
}) ?? []
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

promotionList가 없는 응답에서 .map 호출로 터집니다.

옵셔널 체이닝이 data?.promotionList까지만 적용되어 있어, data는 있고 promotionList가 undefined인 경우 .map에서 TypeError가 납니다(HomeFindAllResponse.promotionList는 스키마상 optional). ?? []는 이 경우를 막지 못합니다.

🐛 제안 수정
     saveCarouselNum(
-      data?.promotionList.map((item) => {
+      data?.promotionList?.map((item) => {
         return item.promotionId;
       }) ?? []
     );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
saveCarouselNum(
data?.promotionList.map((item) => {
return item.promotionId;
})
}) ?? []
);
saveCarouselNum(
data?.promotionList?.map((item) => {
return item.promotionId;
}) ?? []
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/admin/pages/promotion/components/AdminCarousel/AdminCarousel.tsx` around
lines 30 - 34, Update the saveCarouselNum call in AdminCarousel so the optional
promotionList is defaulted to an empty array before invoking map. Preserve the
existing promotionId extraction and ensure both missing data and missing
promotionList produce [] without throwing.

Comment on lines +117 to 136
if (allValid && formData.carousels.length !== 0) {
await updateCarousel(formData);

console.log(formData);

if (allValid && formData.carousels.length !== 0) {
const res = await updateCarousel(formData);
console.log(res);
await console.log(formData);

await openAlert({
title: "캐러셀 수정이 완료되었습니다.",
okCallback: () => {
location.reload();
},
});
} else {
formData.carousels.forEach((item) => {
if (!item.newImageUrl && !item.redirectUrl) {
openAlert({ title: "정보가 없는 캐러셀은 삭제해 주세요." });
} else if (!item.newImageUrl) {
openAlert({ title: "모든 이미지를 삽입해 주세요." });
} else if (!item.redirectUrl) {
openAlert({ title: "모든 링크를 삽입해 주세요." });
}
});
}
} catch (err) {
console.error("Error during file upload or carousel update:", err);
openAlert({ title: "캐러셀 수정 혹은 이미지 저장을 실패했습니다.\n 다시 시도해주세요." });
await openAlert({
title: "캐러셀 수정이 완료되었습니다.",
okCallback: () => {
location.reload();
},
});
} else {
formData.carousels.forEach((item) => {
if (!item.newImageUrl && !item.redirectUrl) {
openAlert({ title: "정보가 없는 캐러셀은 삭제해 주세요." });
} else if (!item.newImageUrl) {
openAlert({ title: "모든 이미지를 삽입해 주세요." });
} else if (!item.redirectUrl) {
openAlert({ title: "모든 링크를 삽입해 주세요." });
}
});
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

캐러셀을 전부 삭제한 뒤 저장하면 아무 반응이 없습니다.

formData.carousels.length === 0이면 updateCarousel도 호출되지 않고 else 분기의 forEach도 순회 대상이 없어 알림이 뜨지 않습니다. 사용자는 저장이 됐는지 알 수 없습니다. 빈 목록에 대한 처리(전체 삭제 저장을 허용하거나, 최소 1개 필요 안내)를 추가해 주세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/admin/pages/promotion/Promotion.tsx` around lines 117 - 136, Handle the
empty formData.carousels case in the save flow so deleting all carousels
produces an explicit outcome. Update the condition around updateCarousel and
validation to either allow saving the empty list and show the existing
completion alert, or show a clear minimum-one-carousel alert; ensure the empty
list does not fall through to a no-op forEach.

Comment on lines +9 to +25
poster: Record<string, ImagePresignedUpload>;
cast: Record<string, ImagePresignedUpload>;
staff: Record<string, ImagePresignedUpload>;
performance: Record<string, ImagePresignedUpload>;
}

export interface ImagePresignedUpload {
uploadUrl: string;
imageKey: string;
}

export interface PresignedAllResponse {
status: number;
message: string;
data: {
performanceMakerPresignedUrls: PresignedResponse;
performanceMakerPresignedUrls: Record<string, ImageInterface>;
performanceMakerPresignedUploads: PresignedResponse;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 스키마 정의와 수동 타입 선언 비교
rg -n -A4 'ImagePresignedUpload:|CarouselPresignedUploadResponse:|BannerPresignedUploadResponse:' src/typings/api/schema/index.ts
rg -n -B2 -A6 'interface ImagePresignedUpload' src
# uploadUrl 사용처
rg -n '\.uploadUrl' src

Repository: TEAM-BEAT/BEAT-Client

Length of output: 1813


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- src/apis/domains/files/api.ts lines 1-120 ---\n'
sed -n '1,120p' src/apis/domains/files/api.ts

printf '\n--- src/apis/domains/files/api.ts usages around presigned all response ---\n'
rg -n -B5 -A25 'PresignedAllResponse|getPresignedA|presigned|upload.*ImagePresignedUpload|data:.*ImagePresignedUpload' src/apis/domains/files/api.ts

printf '\n--- Register.tsx upload checks and calls ---\n'
sed -n '160,270p' src/pages/register/Register.tsx

printf '\n--- ModifyManage.tsx upload checks and calls ---\n'
sed -n '320,365p' src/pages/modifyManage/ModifyManage.tsx

printf '\n--- Promotion.tsx upload checks and calls ---\n'
sed -n '60,90p' src/admin/pages/promotion/Promotion.tsx

Repository: TEAM-BEAT/BEAT-Client

Length of output: 250


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- src/apis/domains/files/api.ts lines 1-120 ---\n'
sed -n '1,120p' src/apis/domains/files/api.ts

printf '\n--- src/apis/domains/files/api.ts usages around presigned all response ---\n'
rg -n -B5 -A25 'PresignedAllResponse|getPresignedA|presigned|upload.*ImagePresignedUpload|data:.*ImagePresignedUpload' src/apis/domains/files/api.ts

printf '\n--- Register.tsxo upload checks and calls ---\n'
sed -n '160,270p' src/pages/register/Register.tsx

printf '\n--- ModifyManage.tsx upload checks and calls ---\n'
sed -n '320,365p' src/pages/modifyManage/ModifyManage.tsx

printf '\n--- Promotion.tsx upload checks and calls ---\n'
sed -n '60,90p' src/admin/pages/promotion/Promotion.tsx

Repository: TEAM-BEAT/BEAT-Client

Length of output: 250


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- src/apis/domains/files/api.ts lines 1-120 ---'
sed -n '1,120p' src/apis/domains/files/api.ts

echo
echo '--- src/apis/domains/files/api.ts usages around presigned all response ---'
rg -n -B5 -A25 'PresignedAllResponse|getPresignedA|presigned|upload.*ImagePresignedUpload|data:.*ImagePresignedUpload' src/apis/domains/files/api.ts

echo
echo '--- Register.tsx upload checks and calls ---'
sed -n '160,270p' src/pages/register/Register.tsx

echo
echo '--- ModifyManage.tsx upload checks and calls ---'
sed -n '320,365p' src/pages/modifyManage/ModifyManage.tsx

echo
echo '--- Promotion.tsx upload checks and calls ---'
sed -n '60,90p' src/admin/pages/promotion/Promotion.tsx

Repository: TEAM-BEAT/BEAT-Client

Length of output: 12733


ImagePresignedUpload 필드는 optional로 맞춰 타입 계약을 맞춰주세요.

src/typings/api/schema/index.ts의 생성 스키마는 uploadUrl?: string; imageKey?: string;, 그리고 캐러셀 스키마도 동일합니다. 현재 필수 필드 선언은 실제 응답과 불일치하며, !upload 체크는 존재하는 객체의 uploadUrl/imageKey 누락을 걸지 못합니다. 필드를 optional로 두고 각 호출부에서 값을 검증한 뒤 S3 PUT을 진행하면 안전합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/apis/domains/files/api.ts` around lines 9 - 25, Update the
ImagePresignedUpload interface so uploadUrl and imageKey are optional, matching
the generated schema contract. Then update each call site using
ImagePresignedUpload to validate both values before initiating the S3 PUT,
including cases where the upload object exists but either field is missing.

@move-hoon
move-hoon merged commit 5187403 into develop Jul 27, 2026
6 of 7 checks passed
@github-project-automation github-project-automation Bot moved this from ✅Todo to 🎉Done in 🌱beat-board Jul 27, 2026
@pepperdad

Copy link
Copy Markdown
Member

멋지네요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♻️ REFACTOR 프로덕션 코드 리팩토링

Projects

Status: 🎉Done

Development

Successfully merging this pull request may close these issues.

[ Refactor ] 전체 이미지 presigned 업로드 계약 동기화

3 participants