Repository navigation
bug: 엑셀이 아닌 파일 업로드가 500을 반환하는 문제 (#79) - #80
Merged
Merged
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (3)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
개요
확장자만
.xlsx로 바꾼 비엑셀 파일을 업로드하면 500이 나던 것을 400 + 행동 가능한 메시지로 고친다.Closes #79
운영 재현 (수정 전)
FE가 서버 장애로 판단했고, 사용자는 무엇을 고쳐야 하는지 알 수 없었다. 실제로는 파일을 변환해 오면 되는 상황이다.
원인
1.
FileValidator를 통과한다. 확장자와 ZIP 매직넘버(50 4B 03 04)만 검사하는데, HWPX도 ZIP 컨테이너라 둘 다 통과한다.2.
ExcelParser가 POI의 런타임 예외를 잡지 않았다.IOException만 잡는데 POI는 전부RuntimeException계열로 던진다.org.apache.poi.ooxml.POIXMLException("Package should contain a content type part [M1.13]")
org.apache.poi.EmptyFileException변경 내용
워크북을 여는 일만 하는
openWorkbook()을 분리해 거기서 POI 예외를FileException으로 매핑했다. 이 메서드는 워크북 생성만 하므로 우리가 던진FileException을 삼킬 위험이 없다 — 그래서RuntimeException을 통째로 잡아도 안전하고, POI가 버전에 따라 다른 예외 타입을 던져도 새지 않는다.FileErrorCode.NOT_AN_EXCEL_FILE(400)을 추가했다. 메시지는 다음에 할 행동을 담았다.부수 효과
MappingConfirmService가 저장된 파일을 다시 파싱하는 경로도 같이 막힌다. 그쪽은FileValidator를 거치지 않아 같은 500 경로가 열려 있었다.테스트
ExcelParserInvalidInputTest5개 추가. 전체 125개 통과.HWPX 유사 ZIP이 ZIP 매직넘버 검사를 통과한다는 전제 자체를 단언해 고정했고, 마지막 테스트는 네 가지 잘못된 입력 전부에 대해 처리되지 않은 런타임 예외가 새지 않는다는 것을 확인한다.
FE에 전달할 것
이 PR이 머지돼도 해당 파일은 여전히 업로드되지 않는다 — 엑셀 파일이 아니기 때문이다. 달라지는 건 500 대신 400과 변환 방법 안내를 받는 것이다.
기간제 근로자 관리서식.hwpx.xlsx는 한글 문서를 이름만 바꾼 것으로 보인다. 엑셀에서 열어.xlsx로 다시 저장한 파일이 필요하다.참고 — 함께 확인한 것
운영 에러 응답에 CORS 헤더가 정상으로 붙는다(
access-control-allow-origin,access-control-expose-headers: Content-Disposition). #32의 "에러 응답에 CORS 헤더 누락"은 현재 재현되지 않는다 — #60/#43으로 해소된 것으로 보인다.Summary by CodeRabbit
.xlsxwithout being converted to an Excel workbook.