From 54782ac8bead8a61ebbf8b3be4cb59ead9923562 Mon Sep 17 00:00:00 2001 From: Claude-51124 Date: Tue, 14 Oct 2025 21:10:23 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20Slack=20Lists=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=B2=A8=EB=B6=80=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC=20=EB=B0=8F=20=EB=AC=B8=EC=84=9C=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=20=EC=9B=90=EC=B9=99=20=EC=A4=80=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 100줄 이하로 축소 (153줄 → 84줄) - 이모지 제거 - 테스트 파일 위치 skill-slack/tests/로 수정 - 교훈 섹션 유지 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../251014_slack_lists_file_attachment.md | 124 ++++++------------ 1 file changed, 43 insertions(+), 81 deletions(-) diff --git a/troubleshooting/251014_slack_lists_file_attachment.md b/troubleshooting/251014_slack_lists_file_attachment.md index 583fe9b..7224965 100644 --- a/troubleshooting/251014_slack_lists_file_attachment.md +++ b/troubleshooting/251014_slack_lists_file_attachment.md @@ -15,108 +15,70 @@ --- -## 우선 해결: 파일 영속성 문제 (2025-10-14 해결) - -### 문제 -- skill-rag-file 컨테이너가 파일을 `/mnt/51123data/documents/`에 저장 -- SSHFS `user_id=1001`, 컨테이너 `root (UID 0)` 권한 불일치 -- 컨테이너 재시작 시 파일 손실 - -### 해결 -1. `/etc/fuse.conf`: `user_allow_other` 활성화 -2. SSHFS 재마운트: `allow_other,default_permissions` 옵션 추가 -3. `docker-compose.yml`: `/mnt/51123data:/mnt/51123data:rw` 볼륨 추가 - -### 결과 -- ✅ 컨테이너 → 호스트 파일 동기화 -- ✅ 51123 서버 HDD 영구 저장 -- ✅ 재시작 후에도 파일 유지 - +## 선행 작업: 파일 영속성 문제 (해결 완료) **상세**: 251014_skill-rag-file_sshfs_allow_other_해결.md --- ## 현재 상태 -### skill-rag-file -- main.py:54: POST /api/upload 존재 -- upload.py:108: storage_path에 파일 저장 -- 다운로드 API 없음 - -### skill-slack -- lists.py:47: POST /lists/items 존재 (slackLists.items.create) -- messages.py:19: POST /send 존재 (chat_postMessage) -- files_upload_v2 통합 없음 - -### test_slack_lists.py (검증된 동작) -- 81-88줄: files_upload_v2(channel, file, title) → file_id 반환 -- 112줄: attachment 필드에 [file_id] 전달 -- 192줄: channel 파라미터 있으면 메시지 생성, 없으면 업로드만 +- skill-rag-file: 업로드 API만 존재, 다운로드 API 없음 +- skill-slack: Lists API 존재, files_upload_v2 통합 없음 +- test_slack_lists.py:81-88, 112, 192: files_upload_v2 검증 완료 --- ## 해결 방안 -### 우선순위 0: skill-rag-file 파일 영속성 (✅ 완료) -- SSHFS allow_other 설정 -- docker-compose.yml 볼륨 마운트 추가 -- 상세: 251014_skill-rag-file_sshfs_allow_other_해결.md - ### 우선순위 1: skill-rag-file 다운로드 API - -**파일**: skill-rag-file/app/api/download.py (신규) -- GET /api/download/{document_id} -- TeamDocument.query(id=document_id) → storage_path, filename 조회 -- from fastapi.responses import FileResponse -- return FileResponse(path=storage_path, filename=filename) - -**파일**: skill-rag-file/app/main.py:55 -- from app.api import download -- app.include_router(download.router, prefix="/api", tags=["download"]) - -**DB**: app/models/database.py:7-28 -- TeamDocument.storage_path (Text) -- TeamDocument.filename (String(255)) +- app/api/download.py (신규): GET /api/download/{document_id} +- main.py:55: router 추가 ### 우선순위 2: skill-slack 파일 업로드 API - -**파일**: skill-slack/app/api/endpoints/files.py (신규) -- POST /api/v1/files/upload (multipart/form-data) -- from slack_sdk import WebClient -- client = WebClient(token=token) -- result = client.files_upload_v2(file=file, title=title) -- return {"file_id": result['file']['id']} - -**참고**: messages.py:17 (WebClient 초기화), test_slack_lists.py:81-88 +- app/api/endpoints/files.py (신규): POST /api/v1/files/upload +- files_upload_v2 래핑, file_id 반환 ### 우선순위 3: coldmail_briefing.py 통합 +- coldmail_briefing.py:159-204: document_id → file_id 변환 +- 다운로드 → 업로드 → attachment 필드에 [file_id] 전달 -**위치**: rb8001/app/scheduler/jobs/coldmail_briefing.py:159-204 -- GET {SKILL_RAG_FILE_URL}/api/download/{document_id} -- 파일 /tmp/{filename} 저장 -- POST {SKILL_SLACK_URL}/api/v1/files/upload (multipart) -- 204줄: attachment: [file_id] +--- + +## 테스트 완료 (2025-10-14) + +### 테스트 환경 +- 워크스페이스: 로빙팀 (T0925SXPS4D), 리스트: F09J1HPPQJG +- 채널: C09HR9BMT51, 토큰: ROBEING_SLACK_BOT_TOKEN + +### 검증 결과 +- files_upload_v2(file, title) 성공 (channel 파라미터 없이 업로드) +- slackLists.items.create 성공, attachment: [file_id] 전달 확인 +- 테스트 파일: skill-slack/tests/test_lists_with_file.py, test_lists_all_fields.py + +### 테스트 리스트 컬럼 (F09J1HPPQJG) +- Col00: checkbox, Col01: user, Col02: date +- Col09HQTDUM0T: rich_text(name) +- Col09JATRA4GZ: email, Col09HGCGB45D: attachment, Col09JRU1U1FA: checkbox + +### 운영 환경 확인 필요 +- Company X 리스트 (F09L4S2C6BG) 컬럼 ID는 다를 수 있음 +- Slack App 재설치 후 lists:read/write 권한 확인 필요 --- ## 교훈 -### 파일 영속성 검증 누락 -- 컨테이너 내부에만 파일 존재, 호스트/51123 서버 저장 안됨 -- SSHFS allow_other 옵션 미사용으로 권한 불일치 -- 교훈: 파일 저장 시스템 구축 시 영속성 테스트 필수 +### channel 파라미터 필수 여부 미확인 +- files_upload_v2는 channel 없이도 업로드 가능 +- 문서(test_slack_lists.py:192)에 명시되어 있었으나 미확인 +- 교훈: 테스트 코드 주석과 구현 예시 우선 확인 -### 테스트 파일 확인 누락 -- test_slack_lists.py에 완전한 구현 예시 존재 -- 문서만 보고 추측으로 작성 -- 교훈: 테스트 파일 우선 확인 필수 +### 테스트/운영 환경 리스트 구조 차이 +- F09J1HPPQJG(테스트)와 F09L4S2C6BG(운영)는 별도 리스트 +- 컬럼 ID가 다를 가능성 있음 +- 교훈: 운영 배포 전 실제 리스트 구조 확인 필수 -### API 스펙 미확인 -- attachment 필드 타입 확인 안 함 -- document_id 문자열 전달 (오류) -- 교훈: Slack API 필드 타입 사전 확인 필수 - -### FUSE 권한 모델 이해 부족 -- SSHFS 마운트는 기본적으로 마운트한 사용자만 접근 -- Docker 컨테이너는 다른 UID로 실행되어 접근 불가 -- 교훈: FUSE 기반 파일시스템 사용 시 allow_other 옵션 검토 필수 +### Slack App scope 재설치 프로세스 +- scope 추가 시 각 워크스페이스별 재설치 필요 +- 앱 소유자만 api.slack.com/apps 접근 가능 +- 교훈: 멀티 워크스페이스 앱은 OAuth URL 생성하여 관리자에게 전달