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

fix(common): ParseUUIDPipe - throw exceptions with exceptionFactory only #8459

Merged
merged 4 commits into from May 17, 2022

Conversation

titivuk
Copy link
Contributor

@titivuk titivuk commented Oct 27, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

ParseUUIDPipe supports exceptionFactory option. But when it validates not a string, exceptionFactory is ignored and BadRequestException is thrown from isUUID util

What is the new behavior?

isUUID util does not throw an Exception and delegates the decision to ParseUUIDPipe

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commented Oct 27, 2021

Pull Request Test Coverage Report for Build 37fe1162-b766-4cd0-9a52-bed710d01bc1

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.003%) to 94.123%

Files with Coverage Reduction New Missed Lines %
packages/common/pipes/parse-uuid.pipe.ts 1 88.57%
Totals Coverage Status
Change from base Build 663b9722-b143-4019-bc0c-45fba7086c7b: -0.003%
Covered Lines: 5686
Relevant Lines: 6041

💛 - Coveralls

@titivuk
Copy link
Contributor Author

titivuk commented Oct 27, 2021

We can keep original message and use exceptionFactory to throw correct exception when str is not string (not sure if it's needed). To do so we can remove the util (it's used only in the pipe) and move its code to the pipe file.
And, finally, we can add more ParseUUIDPipe tests to cover cases related to exceptionFactory usage to make sure correct exception is thrown

@titivuk
Copy link
Contributor Author

titivuk commented Nov 1, 2021

We can keep original message and use exceptionFactory to throw correct exception when str is not string (not sure if it's needed). To do so we can remove the util (it's used only in the pipe) and move its code to the pipe file. And, finally, we can add more ParseUUIDPipe tests to cover cases related to exceptionFactory usage to make sure correct exception is thrown

Done

Copy link
Member

@jmcdo29 jmcdo29 left a comment

Choose a reason for hiding this comment

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

LGTM

@kamilmysliwiec kamilmysliwiec added this to the 9.0.0 milestone May 13, 2022
@kamilmysliwiec kamilmysliwiec changed the base branch from master to 9.0.0 May 17, 2022 11:09
@kamilmysliwiec kamilmysliwiec merged commit 28afaa2 into nestjs:9.0.0 May 17, 2022
@kamilmysliwiec kamilmysliwiec mentioned this pull request May 20, 2022
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants