Skip to content

❗ [버그][AI] PlaceExtractionResponse 역직렬화 실패 - AI 서버 응답의 "message" 필드 미처리` #36

@Cassiiopeia

Description

@Cassiiopeia

🐛 버그 설명

POST /api/content/analyze 호출 시, 백엔드가 AI 서버로부터 정상 응답(200 OK)을 받았음에도 EXTERNAL_API_ERROR(502)를 반환합니다.

AI 서버 응답에 포함된 message 필드를 PlaceExtractionResponse DTO가 인식하지 못해 Jackson 역직렬화 예외가 발생합니다.

📍 에러 로그

AI server raw response: httpStatus=200, responseBody={"received":true,"message":"Processing started"}

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: 
Unrecognized field "message" (class kr.suhsaechan.mapsy.ai.dto.PlaceExtractionResponse), 
not marked as ignorable (3 known properties: "received", "status", "contentId"])
  at kr.suhsaechan.mapsy.ai.service.AiServerService.sendPlaceExtractionRequest(AiServerService.java:81)

🔍 원인 분석

AI 서버 실제 응답:

{"received": true, "message": "Processing started"}

백엔드 DTO (PlaceExtractionResponse.java):

public class PlaceExtractionResponse {
    private UUID contentId;    // ✅
    private Boolean received;  // ✅
    private String status;     // ✅
    // ❌ message 필드 없음
}

Jackson이 strict mode로 동작하여, 알 수 없는 필드(message)가 있으면 예외를 던집니다.

✅ 제안하는 수정 방법

방법 A (권장): 알 수 없는 필드 무시

@JsonIgnoreProperties(ignoreUnknown = true)  // 추가
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PlaceExtractionResponse {
    private UUID contentId;
    private Boolean received;
    private String status;
}

방법 B: message 필드 추가

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PlaceExtractionResponse {
    private UUID contentId;
    private Boolean received;
    private String status;
    private String message;  // 추가
}

방법 A를 권장합니다. AI 서버 응답 형식이 변경되더라도 백엔드가 깨지지 않아 방어적입니다.

📁 수정 대상 파일

  • MS-AI/src/main/java/kr/suhsaechan/mapsy/ai/dto/PlaceExtractionResponse.java

🔗 재현 방법

  1. Flutter 앱에서 SNS URL 입력 후 분석 요청
  2. 백엔드 → AI 서버 호출 성공 (200 OK)
  3. 응답 역직렬화 시 UnrecognizedPropertyException 발생
  4. EXTERNAL_API_ERROR (502)로 클라이언트에 반환

Metadata

Metadata

Assignees

Labels

긴급긴급한 작업작업 완료작업 완료 상태인 경우 (이슈 폐쇄)

Type

No type

Projects

Status

작업 완료

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions