임동욱 임동욱 09-17
fix: 저장된 추가 이미지를 다시 읽지 못하면 빈 파일을 올리지 않고 사유를 알린다
이미지 파일은 서버 디스크에만 있고 DB 행은 공유되므로, dev에서 올린 이미지를 로컬 백엔드로
붙어 다시 읽으면 200에 빈 본문이 온다(백엔드가 없는 파일에 404 대신 빈 200을 준다 — 보고함).
그 0KB 파일이 묶음 재업로드에 섞여 500이 났다. 빈 본문은 실패로 다뤄 안내하고, 존재 확인도
content-length 0을 없는 것으로 센다.

Co-Authored-By: Claude Opus 5 
@170e52570dc43aa7af7152d024c094316d2f39f7
app/(protected)/(basic)/system/merchant-details/_actions.ts
--- app/(protected)/(basic)/system/merchant-details/_actions.ts
+++ app/(protected)/(basic)/system/merchant-details/_actions.ts
@@ -154,10 +154,13 @@
     throw new InputError(INVALID_REQUEST_MESSAGE);
   }
   const response = await fetch(url, { cache: 'no-store' });
-  if (!response.ok) {
-    throw new InputError('저장된 이미지를 다시 읽지 못했습니다. 잠시 후 다시 시도해 주세요.');
+  const blob = response.ok ? await response.blob() : null;
+  // 파일이 없어도 백엔드가 200에 빈 본문으로 답한다(보고함) — 빈 파일을 다시 올리면 500이 난다.
+  if (!blob || blob.size === 0) {
+    throw new InputError(
+      `저장된 추가 이미지 ${fileSn}번을 다시 읽지 못했습니다. 이 서버에 파일이 없을 수 있으니 이미지를 다시 올려 주세요.`
+    );
   }
-  const blob = await response.blob();
   const extension = blob.type.split('/')[1] || 'jpg';
   return new File([blob], `image-${fileSn}.${extension}`, { type: blob.type });
 }
lib/data/repositories/merchant-detail-repository.ts
--- lib/data/repositories/merchant-detail-repository.ts
+++ lib/data/repositories/merchant-detail-repository.ts
@@ -159,7 +159,9 @@
       { method: 'GET', timeout: PROBE_TIMEOUT_MS },
       (response) => {
         response.destroy();
-        resolve((response.statusCode ?? 500) < 400);
+        // 파일이 없어도 200에 빈 본문으로 답하는 서버가 있다(보고함) — 빈 것은 없는 것으로 본다.
+        const isEmpty = response.headers['content-length'] === '0';
+        resolve((response.statusCode ?? 500) < 400 && !isEmpty);
       }
     );
     request.on('timeout', () => {
Add a comment
List