Skip to content

[FIX#321] 프로그램 관리 웹훅 API body 제거#322

Merged
HongGeonUi merged 2 commits into
mainfrom
fix#321
Jan 27, 2026
Merged

[FIX#321] 프로그램 관리 웹훅 API body 제거#322
HongGeonUi merged 2 commits into
mainfrom
fix#321

Conversation

@HongGeonUi

@HongGeonUi HongGeonUi commented Jan 27, 2026

Copy link
Copy Markdown
Collaborator

📝 작업 내용

  • 웹훅 API body 제거

🎯 관련 이슈

Closes #321

🔄 변경사항

👀 리뷰 포인트

📱 스크린샷/영상

Before

After

Summary by CodeRabbit

릴리스 노트

  • 버그 수정

    • 프로그램 리더 변경 처리 안정성을 향상했습니다.
    • 프로그램을 찾을 수 없는 경우 404 응답으로 적절히 처리합니다.
  • 변경

    • 리더 정보는 웹훅 페이로드 대신 최신 프로그램 데이터에서 조회하도록 변경되었습니다.
    • 웹훅 요청에서 프로그램 ID(data.id) 필수화를 반영하여 처리 흐름을 단순화하고 결과 응답을 명확화했습니다.

✏️ Tip: You can customize this high-level summary in your review settings.

@HongGeonUi HongGeonUi self-assigned this Jan 27, 2026
@HongGeonUi HongGeonUi added 🐛 bug 버그 BE 백엔드 labels Jan 27, 2026
@vercel

vercel Bot commented Jan 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
youthit Ready Ready Preview, Comment Jan 27, 2026 1:24pm

@coderabbitai

coderabbitai Bot commented Jan 27, 2026

Copy link
Copy Markdown

Walkthrough

웹훅 페이로드의 rollup 기반 리더 정보 추출을 제거하고, Notion에서 getProgramById(data.id)로 프로그램을 조회해 leaderUserIdleaderNickname을 사용하도록 변경했다. 프로그램 미존재 시 404를 반환하며, updateCommunityLeader에 조회한 program을 전달하도록 호출부와 시그니처를 수정했다.

Changes

Cohort / File(s) 변경 사항
웹훅 컨트롤러 및 라우트
be/functions/src/controllers/programController.js, be/functions/src/routes/programs.js
웹훅에서 rollup으로 리더 정보 파싱 제거 → data.id로 프로그램 조회. 프로그램 not-found 시 404 응답 추가. 라우트 스키마에서 data.id 필수로 변경 및 응답/오류 설명 업데이트.
애플리케이션 서비스
be/functions/src/services/programApplicationService.js
updateCommunityLeader(programPageId, newLeaderUserId, nickname)updateCommunityLeader(programPageId, newLeaderUserId, nickname, program = null) 시그니처 확장. program 전달 시 중복 조회 방지, 리더 없음 케이스(제거/스킵) 처리 경로 추가 및 반환 구조에 leaderRemoved 등 필드 추가.
프로그램 서비스(데이터 포맷팅)
be/functions/src/services/programService.js
프로그램 포맷에 leaderUserId(rollup에서 추출)를 추가해 getProgramById 반환값에 포함되도록 변경.

Sequence Diagram(s)

sequenceDiagram
    participant Webhook as Webhook Request
    participant Controller as programController
    participant ProgramSvc as programService
    participant AppSvc as programApplicationService
    participant Community as Community DB

    Webhook->>Controller: POST /webhooks/leader-change (body.data.id)
    Controller->>ProgramSvc: getProgramById(data.id)
    ProgramSvc-->>Controller: program { leaderUserId, leaderNickname, ... }

    alt program not found
        Controller-->>Webhook: 404 NOT_FOUND
    else program found
        Controller->>AppSvc: updateCommunityLeader(programPageId, newLeaderUserId, nickname, program)
        AppSvc->>Community: transaction: adjust admin/member roles
        Community-->>AppSvc: update result
        AppSvc-->>Controller: result (leaderUpdated/leaderRemoved/skipped)
        Controller-->>Webhook: 200 JSON response
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • [FEAT#307] 리더사용자변경시 동기화 추가 #308: 동일 웹훅 흐름 리팩토링 — 프로그램 조회로 리더 데이터 소스 변경 및 updateCommunityLeaderprogram 파라미터 추가 관련.
  • #172: programService.getProgramById 포맷 변경과 관련된 PR로, leader 관련 필드 추가 패턴이 유사함.

Suggested labels

♻️ refactor

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning PR 설명에서 '작업 내용'과 '관련 이슈' 섹션만 채워져 있고, '변경사항'과 '리뷰 포인트' 섹션이 비어있어 완성도가 낮다. '변경사항' 섹션에 웹훅 처리 로직 변경 및 유효성검증 추가 등 구체적 변경 내용을, '리뷰 포인트'에 검토 중점을 명시해주세요.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 이슈 #321의 주요 목표인 '웹훅 API body 제거'를 명확히 반영하고 있어서 변경사항의 핵심을 잘 전달하고 있다.
Linked Issues check ✅ Passed 코드 변경이 이슈 #321의 요구사항인 '프로그램 관리 웹훅 API body 제거'를 충족하고 있으며, 웹훅 payload 구조 변경 및 유효성검증 추가로 구현되었다.
Out of Scope Changes check ✅ Passed 4개 파일의 모든 변경사항이 웹훅 API body 제거 및 관련 검증 로직 개선으로 이슈 범위 내에 있으며, 불필요한 변경은 없다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

@github-actions

github-actions Bot commented Jan 27, 2026

Copy link
Copy Markdown

🔧 빌드 상태: 성공! ✅

Firebase Functions 빌드 및 에뮬레이터 기동이 성공적으로 완료되었습니다! 🎉

✅ 체크 완료

  • 🔧 Backend Build (Emulator): 성공

📊 상세 정보

  • Commit: 3d6b9c8
  • Branch: fix#321
  • 빌드 완료 시간: 2026. 1. 27. 오후 10:23:58

🚀 Functions 빌드 및 실행에 문제가 없습니다. 머지 가능합니다!

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
be/functions/src/services/programService.js (1)

575-619: leaderUserId는 name/id로 뽑아줘

지금은 plain_text가 없어서 거의 null로 떨어질 거야. getRollupValues 결과는 name/id 기반이라 그걸 우선 사용해야 리더 변경 웹훅이 안 깨져.

🛠️ 수정 제안
-    const leaderUserId = leaderUserIdRollup?.value?.[0]?.plain_text || null;
+    const leaderUserId =
+      leaderUserIdRollup?.value?.[0]?.name ??
+      leaderUserIdRollup?.value?.[0]?.id ??
+      null;
be/functions/src/services/programApplicationService.js (1)

1149-1166: updateCommunityLeader 새 파라미터 문서화 추가해줘

signature에 program이 추가됐는데 JSDoc에 빠져있어. 코딩 가이드라인 기준으로.

📝 JSDoc 보완
-   * `@param` {string} nickname - 리더 닉네임
+   * `@param` {string} nickname - 리더 닉네임
+   * `@param` {Object|null} program - 미리 조회한 프로그램 데이터 (없으면 내부 조회)

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
be/functions/src/controllers/programController.js (1)

449-485: 웹훅 data.id 타입/공백 체크 추가해줘.
지금은 truthy만 보는데 객체/공백이면 Notion 호출로 넘어가서 500으로 떨어질 수 있어. 400으로 바로 컷하는 게 좋아.

🛠️ 제안 수정
-      if (!data || !data.id) {
+      if (!data || typeof data.id !== 'string' || !data.id.trim()) {
         const error = new Error('유효하지 않은 웹훅 데이터입니다');
         error.code = 'BAD_REQUEST';
         error.statusCode = 400;
         return next(error);
       }
 
       // 1. 프로그램 페이지 ID 추출
-      const programPageId = data.id;
+      const programPageId = data.id.trim();
be/functions/src/routes/programs.js (1)

596-613: Swagger에 data 자체도 required로 표시해줘.
컨트롤러가 data 없으면 400이라 스펙도 맞춰두는 게 좋아.

🧾 스펙 보강 예시
 *         schema:
 *           type: object
+ *           required:
+ *             - data
 *           properties:
 *             data:
 *               type: object
 *               required:
 *                 - id
🤖 Fix all issues with AI agents
In `@be/functions/src/services/programApplicationService.js`:
- Around line 1274-1282: The response can return undefined for wasAlreadyAdmin
in the leader-removal branch; update the return object to normalize that value
to false when missing by using a default (e.g. replace result.wasAlreadyAdmin
with result.wasAlreadyAdmin ?? false or Boolean(result.wasAlreadyAdmin)) so
wasAlreadyAdmin is always a boolean; adjust the same return that sets
communityId, newLeaderUserId, previousLeaderUserId, leaderRemoved to ensure
consistency (references: result.wasAlreadyAdmin, leaderRemoved,
newLeaderUserId).
🧹 Nitpick comments (1)
be/functions/src/services/programApplicationService.js (1)

1159-1166: JSDoc에 program 파라미터도 명시해줘.
시그니처가 늘었는데 주석은 그대로라서 헷갈릴 수 있어. 옵션 파라미터로 추가해두자. As per coding guidelines, ...

✍️ JSDoc 업데이트 예시
 /**
  * `@param` {string} programPageId - 노션 프로그램 페이지 ID (원본)
  * `@param` {string} newLeaderUserId - 새 리더 Firebase UID
  * `@param` {string} nickname - 리더 닉네임
+ * `@param` {Object|null} [program] - 이미 조회한 프로그램 (옵션)
  * `@returns` {Promise<Object>} 업데이트 결과
  */

Comment thread be/functions/src/services/programApplicationService.js
@HongGeonUi
HongGeonUi merged commit cad916f into main Jan 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BE 백엔드 🐛 bug 버그

Projects

None yet

Development

Successfully merging this pull request may close these issues.

프로그램 관리 자동화 오류

1 participant