diff --git a/troubleshooting/251014_slack_lists_file_attachment.md b/troubleshooting/251014_slack_lists_file_attachment.md index 373831e..1032e90 100644 --- a/troubleshooting/251014_slack_lists_file_attachment.md +++ b/troubleshooting/251014_slack_lists_file_attachment.md @@ -30,7 +30,8 @@ coldmail_briefing.py:207에서 document_id를 attachment에 전달하지만, Sla - `select(TeamDocument).where(TeamDocument.id == document_id)` - `db.execute(stmt)`, `result.scalar_one_or_none()` - 없으면 HTTPException(404) -**반환**: `FileResponse(document.storage_path, media_type="application/pdf")` +**반환**: `FileResponse(document.storage_path, media_type=document.mime_type or "application/pdf")` +**주의**: MIME 타입은 DB에서 가져오기 (PDF 고정 금지) **등록**: skill-rag-file/app/main.py:55 이후 - `from app.api import upload, search, download` - `app.include_router(download.router, prefix="/api", tags=["download"])` @@ -45,6 +46,7 @@ coldmail_briefing.py:207에서 document_id를 attachment에 전달하지만, Sla - `client = WebClient(token or settings.SLACK_BOT_TOKEN)` - 임시 파일 저장 → `client.files_upload_v2(file=temp_path, title=title)` - 업로드 후 임시 파일 삭제 +**주의**: 임시 파일 저장 시 원본 filename 유지 필요 **반환**: `{"file_id": result["file"]["id"], "url_private": result["file"]["url_private"]}` **에러**: HTTPException(400 or 500) **등록**: skill-slack/app/api/__init__.py:4, 13 수정 @@ -56,14 +58,19 @@ coldmail_briefing.py:207에서 document_id를 attachment에 전달하지만, Sla **파일 변환 로직** (coldmail_briefing.py:189 이후, 191 이전): - GET `{SKILL_RAG_FILE_URL}/api/download/{document_ids[0]}` → pdf_content -- aiohttp.FormData(): file, title 추가 -- POST `{SKILL_SLACK_URL}/api/v1/files/upload` → file_id +- aiohttp.FormData(): file (filename, content_type 명시), title 추가 +- headers: `{"X-API-Key": os.getenv("SKILL_SLACK_API_KEY")}` +- POST `{SKILL_SLACK_URL}/api/v1/files/upload` + headers → file_id - 실패 시 file_id = None, logger.error() **attachment 필드 수정** (coldmail_briefing.py:207): - 변경 전: `[f"document_{doc_id}" for doc_id in document_ids][:1]` - 변경 후: `[file_id] if file_id else []` +**Lists API 호출 수정** (coldmail_briefing.py:212-214): +- 현재 X-API-Key 헤더 없음 → 401 발생 +- headers 추가: `{"X-API-Key": os.getenv("SKILL_SLACK_API_KEY")}` + --- ## 테스트 완료 @@ -83,4 +90,4 @@ coldmail_briefing.py:207에서 document_id를 attachment에 전달하지만, Sla ### 리스트 컬럼 구조 - F09J1HPPQJG(테스트) ≠ F09L4S2C6BG(운영) -- 교훈: 운영 배포 전 실제 컬럼 ID 확인 필수 +- 교훈: 컬럼 ID 하드코딩 금지, slack_lists_service.py:92-119 동적 매핑 사용