Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge: (#301) Request 개선 #311

Merged
merged 13 commits into from
Jan 25, 2023
Merged

Conversation

khcho0125
Copy link
Member

@khcho0125 khcho0125 commented Jan 23, 2023

작업 내용 설명

  • Request 핸들링 개선
  • ModelAttribute 제거

주요 변경 사항

  • 요청에서 Value Class를 사용해 얻는 메리트가 크지 않다고 생각해 사용하지 않기로 했습니다.
  • ModelAttribute를 사용하는 것이 Validation, PropertyName 등의 문제로 인해 오히려 독이 된다고 판단하여 제거했습니다.

요청 파라미터에 대한 핸들링이 되지 않았던 문제

# MethodArgumentNotValidException

{
    "status": 400,
    "message": "잘못된 입력값입니다.",
    "field_errors": [
        {
            "field": "nickname",
            "value": null,
            "reason": "널이어서는 안됩니다"
        }
    ]
}

위와 같이 MethodArgumentNotValidException가 핸들링되야 하지만 아래처럼 HttpMessageNotReadableException으로 핸들링되어 적절한 메시지를 얻지 못했습니다.

# HttpMessageNotReadableException

{
    "status": 400,
    "message": "잘못된 입력값입니다.",
    "field_errors": [
        {
            "field": "",
            "value": "",
            "reason": "Instantiation of [simple type, class team.comit.simtong.domain.user.dto.request.SignUpWebRequest] value failed for JSON property nickname due to missing (therefore NULL) value for creator parameter nickname which is a non-nullable type"
        }
    ]
}

NoArgmentConstructor이 필요한 것으로 추정 → kotlin-dsl의 no-arg 플러그인 사용했지만 효과 없음 → Nullable + Null Validation 사용

  • CustomFieldError의 value 필드를 Nullable로 변경해 Null 값을 핸들링할 수 있도록 변경
  • @RequestHeader, @RequestParam, @RequestPart 요청시 Nullable + Null Validation 적용해 확실한 예외처리
  • AuthCode의 defaultValue → generate 로 함수 명 변경
  • 이메일 요청은 NotBlank + Email → NotEmpty + Email로 유효성 검사 변경
  • 인자값이 여러개인 함수는 인자 매핑 스타일로 변경
  • Request private 필드 접근 제한자 적용

체크리스트

  • 어플리케이션 구동(혹은 테스트)시 오류는 없나요?
  • 생성된 코드에 Javadoc 주석을 추가 하였나요?
  • 생성된 코드에 대한 테스트 코드가 작성 되었나요?

관련 이슈

@khcho0125 khcho0125 added performance 성능을 개선 할 경우 refactor 코드 리팩토링 할 경우 labels Jan 23, 2023
@khcho0125 khcho0125 requested a review from softpeanut as a code owner January 23, 2023 12:18
@khcho0125 khcho0125 self-assigned this Jan 23, 2023
@codecov
Copy link

codecov bot commented Jan 23, 2023

Codecov Report

Merging #311 (3069b27) into develop (8b24f24) will increase coverage by 0.51%.
The diff coverage is 7.97%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #311      +/-   ##
=============================================
+ Coverage      38.92%   39.43%   +0.51%     
+ Complexity       392      381      -11     
=============================================
  Files            240      234       -6     
  Lines           2944     2888      -56     
  Branches          99      102       +3     
=============================================
- Hits            1146     1139       -7     
+ Misses          1792     1743      -49     
  Partials           6        6              
Impacted Files Coverage Δ
...team/comit/simtong/global/error/WebErrorHandler.kt 0.00% <0.00%> (ø)
...comit/simtong/global/error/dto/CustomFieldError.kt 0.00% <0.00%> (ø)
...am/comit/simtong/global/error/dto/ErrorResponse.kt 0.00% <0.00%> (ø)
...mit/simtong/domain/admin/dto/AdminSignInRequest.kt 0.00% <0.00%> (ø)
...am/comit/simtong/domain/common/WebCommonAdapter.kt 0.00% <0.00%> (ø)
...simtong/domain/common/dto/ChangePasswordRequest.kt 0.00% <0.00%> (ø)
.../simtong/domain/common/dto/ResetPasswordRequest.kt 0.00% <0.00%> (ø)
...team/comit/simtong/domain/email/WebEmailAdapter.kt 0.00% <0.00%> (ø)
...it/simtong/domain/email/dto/SendAuthCodeRequest.kt 0.00% <0.00%> (ø)
...n/team/comit/simtong/domain/file/WebFileAdapter.kt 0.00% <0.00%> (ø)
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b24f24...3069b27. Read the comment docs.

@khcho0125 khcho0125 requested a review from softpeanut January 23, 2023 16:52
@sonarcloud
Copy link

sonarcloud bot commented Jan 23, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@softpeanut softpeanut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후에 Response도 private 필드로 변경하면 좋을 것 같습니다 😃
nullable 타입의 !! 는 매우 아쉽지만 지금으로썬 방법이 없네요..

@khcho0125 khcho0125 merged commit 580f5b3 into develop Jan 25, 2023
@khcho0125 khcho0125 deleted the refactor/301-improve-http-request branch January 25, 2023 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance 성능을 개선 할 경우 refactor 코드 리팩토링 할 경우
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants