Skip to content

refactor(core): PhotoUploadRepository.upload() 가 presigned 응답의 fileKey 를 버림 — 호출부가 URL 에서 역산 #1017

Closed

Description

@Sadturtleman

📜 Overview (Required)

POST /files/presigned-url 응답은 fileKey(mindrecords/staging/13/uuid.png)와 fileUrl(그 앞에 CDN 호스트가 붙은 전체 URL)을 둘 다 내려준다(core/network/.../PresignedUrlDto.kt). 그런데 PhotoUploadRepositoryImpl.upload() 는 presigned.fileUrl 만 반환하고 권위 있는 fileKey 를 버린다.

서버는 본문 img src 에서 fileKey 를 기대하므로(#549), 호출부가 URL 에서 문자열로 역산한다.

// feature/mindrecord/presentation/.../util/HtmlText.kt
fun String.toUploadedFileKey(): String =
    if (contains("://")) substringAfter("://").substringAfter('/') else this

이 방식은 fileUrl == "<스킴>://<호스트>/" + fileKey 를 가정한다. CDN 이 경로 프리픽스를 붙이거나(https://cdn/bucket/mindrecords/…) 쿼리스트링이 붙으면 조용히 틀린 키가 나가고, 증상은 #549 가 고친 것과 똑같은 «저장은 됐는데 이미지가 안 뜬다» 다.

무엇을 하면 되나

upload() 반환을 (fileUrl, fileKey) 로 넓히면 추측이 사라진다. 미리보기는 전체 URL 이라야 뜨고 본문에 실을 값은 fileKey 라, 호출부는 두 값이 다 필요하다.

📌 Child Issue(Optional)

No response

📍 Note (Optional)

Activity

  1. OnlyReadOneBook commented on Aug 25, 2026

    @OnlyReadOneBook
    Collaborator

    실서버 실측 — 현재 prefix 에 경로 세그먼트 없음 (긴급도 하향, 이슈는 유지)

    이 이슈가 가정한 "URL 역산이 틀린 키를 만든다"가 지금 운영 설정에서 실제로 일어나는지 확인했습니다.

    측정: 2026-08-25 17:09 KST · POST /api/v1/files/presigned-url (directory=mindrecords) · 업로드는 수행하지 않음

    fileUrl = https://dpy1u4p7yz7bh.cloudfront.net/mindrecords/staging/14/2cd1ee65-….png
    fileKey = mindrecords/staging/14/2cd1ee65-….png
    prefix  = https://dpy1u4p7yz7bh.cloudfront.net/
    

    AWS_PUBLIC_BASE_URL 의 prefix 가 호스트뿐입니다. 현재 역산은 우연히 맞습니다 — 즉 지금 깨진 데이터가 생기고 있지는 않습니다.

    그래도 닫지 않는 이유

    이 값은 DEPLOY_PRODUCTION_ENV secret 안에 있어 레포에서 확인되지 않고, 바뀌어도 FE 는 알 방법이 없습니다. https://cdn.example.net/assets/ 처럼 경로 세그먼트가 붙는 순간 역산은 assets/ 를 키에 섞고, 업로드는 성공하는데 이미지만 깨지는 형태라 적발이 늦습니다. 서버 설정 하나가 클라이언트를 조용히 깨뜨릴 수 있는 결합이 문제의 본질이고, 그건 이번 측정으로 사라지지 않습니다.

    upload() 가 presigned 응답의 fileKey 를 그대로 돌려주면 이 결합 자체가 없어집니다.

    정리: 긴급도는 내려가고(현재 사고 없음), 이슈의 값은 유지됩니다. #1016 에도 같은 결과를 남겨, 그쪽 구현이 역산 방식으로 진행해도 지금은 안전하다는 점을 알렸습니다.

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions