[Feat] 페이지 스냅샷 추가#46
Open
minsoo0506 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
링크 검사 결과에서 사용자가 최종 URL의 페이지 화면을 확인할 수 있도록 페이지 스냅샷 생성 기능을 추가했습니다. 스냅샷 이미지를 API 응답에 직접 포함하지 않고, 서버 로컬 저장소에 PNG로 저장한 뒤 응답에는 스냅샷 상태와
storage_key를 내려주는 방식입니다. (임시)주요 변경 사항:
PageSnapshotResult,PageSnapshotStatus스키마 추가PipelineSuccess.snapshot응답 필드 추가available,skipped,timeout,failed로 구분응답 :
{ "status": "success", "verdict": "safe", "score": 0, "summary": "현재 분석 기준에서 뚜렷한 위험 신호가 확인되지 않았습니다.", "snapshot": { "status": "available", "final_url": "https://example.com/", "storage_key": "aid-snapshot.png", "elapsed_seconds": 0.83, "error": null } }이미지 전달 방식 검토
1. S3/R2/GCS 등 객체 스토리지 사용
흐름:
예시 응답:
{ "snapshot": { "status": "available", "final_url": "https://example.com/", "storage_key": "snapshots/analysis-id.png", "snapshot_url": "https://cdn.example.com/snapshots/analysis-id.png", "elapsed_seconds": 0.83 } }장점:
삭제 방식 예시:
운영 방식:
FastAPI -> S3 private bucket 업로드 -> presigned URL 발급 -> 프론트 표시 -> TTL 후 만료/삭제
2. base64 inline 응답
이미지를 API 응답 JSON 안에 직접 넣는 방식입니다.
예시:
{ "snapshot": { "status": "available", "mime_type": "image/png", "base64": "iVBORw0KGgoAAAANSUhEUg...", "elapsed_seconds": 0.83 } }장점:
단점:
현실적인 사용 조건:
예시 제한:
page_snapshot_inline_max_bytes = 500_000
3. FastAPI 로컬 디스크 + 정적 파일 서빙
흐름:
장점:
단점:
성능 테스트 결과
실제 정상 URL 10개를 대상으로 스냅샷 생성 테스트를 수행했습니다.
테스트 URL:
https://www.youtube.com/
https://www.wikipedia.org/
https://www.apple.com/
https://www.microsoft.com/
https://github.com/
https://www.python.org/
https://fastapi.tiangolo.com/
https://www.postgresql.org/
https://www.mozilla.org/
결과:
테스트 산출물은 로컬 확인용으로 생성했으며 PR 커밋에는 포함하지 않았습니다.
테스트
실행한 검증:
ruff check app/services/page_snapshot.py app/services/pipeline.py app/schemas/page_snapshot.py app/schemas/pipeline.py app/schemas/db_independent_pipeline.py tests/
services/test_page_snapshot.py tests/services/test_pipeline.py
pytest tests/services/test_pipeline.py tests/services/test_page_snapshot.py tests/api/test_analyze_db_independent.py tests/services/test_analysis_callback.py
결과:
참고:
전체 pytest 실행 시 450개 통과, 5개 실패가 있었으나 실패는 기존 작업트리에 남아 있는 OpenAIProvider 테스트 기대값 변경과 관련된 것으로, 이번 페이지 스냅샷 커밋에는 포함하지 않았습니다.
연관 이슈 및 Close 할 이슈
close [FEATURE] 링크 검사 결과에 페이지 스냅샷 제공 #45
Pull Request 체크리스트
TODO