Skip to content

fix: 공공데이터포털 빈 응답 파싱 오류로 인한 500 에러 수정 - #24

Merged
1ub7 merged 1 commit into
developfrom
fix/weather-500-error
Sep 14, 2026
Merged

1ub7 merged 1 commit into
developfrom
fix/weather-500-error

Conversation

@1ub7

@1ub7 1ub7 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

📝 작업 내용

/environment/weather 500 에러 수정. 실제 GPS 좌표로 호출 시 기상청/에어코리아 API가 데이터 없는 응답을 items: ""(빈 문자열)로 내려주는 경우가 있는데 이걸 파싱하다가 예외가 발생해서 500으로 튀던 문제였습니다.

🔧 변경 사항

  • RestTemplateConfig: ObjectMapper에 DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT 옵션 추가 — 빈 문자열 응답을 예외 대신 null로 처리
  • EnvironmentService: getWeather, getSafety 양쪽 모두 items가 null인 경우 빈 리스트로 방어 처리 추가

🧪 테스트 방법

  1. 실제 GPS 좌표로 GET /environment/weather?lat=...&lng=... 호출
  2. 데이터가 없는 지점/시간대에도 500 대신 200 응답(필드는 null 가능)이 오는지 확인
  3. /environment/safety도 동일하게 확인

📌 참고사항

  • 데이터 자체가 없는 경우엔 정상적으로 null 필드가 내려감. 프론트에서 null 처리 필요
  • MappingJackson2HttpMessageConverter 사용 시 Spring Framework 7.0에서 deprecated(제거 예정) 경고 뜨는데 아직 동작에는 문제없음 — 추후 Jackson3 기반 JacksonJsonHttpMessageConverter로 마이그레이션 검토 필요

@1ub7
1ub7 requested a review from s26047-code September 14, 2026 11:51
@1ub7
1ub7 merged commit e2c24bf into develop Sep 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants