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): fallback to empty string for enums when validating (swc builder) #14181

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

kamilmysliwiec
Copy link
Member

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?

Issue Number: #12680

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commented Nov 21, 2024

Pull Request Test Coverage Report for Build 23759b43-a233-4f4f-9d66-b773604ecffe

Details

  • 3 of 6 (50.0%) changed or added relevant lines in 1 file are covered.
  • 29 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 91.952%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/common/pipes/validation.pipe.ts 3 6 50.0%
Files with Coverage Reduction New Missed Lines %
packages/core/injector/injector.ts 29 84.34%
Totals Coverage Status
Change from base Build 1d36b27a-0a3e-4f95-b141-14fcdc7e1b87: -0.04%
Covered Lines: 6810
Relevant Lines: 7406

💛 - Coveralls

@kamilmysliwiec kamilmysliwiec merged commit f7248e2 into master Nov 25, 2024
5 checks passed
@JoCat
Copy link

JoCat commented Dec 2, 2024

Now there are no previous errors. But only the query gives 400 in the condition when the parameter is not specified, even though it is optional.
image
image

UPD
A little bit of research:
Before the fix, not passing a value caused a 500 error in the browser and a TypeError in the code. Passing a value that was not in the enum sample resulted in a 400 error, passing the correct value was handled correctly.
After the fix, failure to pass a value causes the same 400 error as with an invalid enum value.

@kamilmysliwiec
Copy link
Member Author

@JoCat could you create an issue with a minimum reproduction repository?

@JoCat
Copy link

JoCat commented Dec 3, 2024

@JoCat could you create an issue with a minimum reproduction repository?

It was in the same issue: #12680 (comment)

@kamilmysliwiec
Copy link
Member Author

It was a slightly different issue, hence different repository

@JoCat
Copy link

JoCat commented Dec 3, 2024

There error is related and also reproduced in the same repository

@JoCat
Copy link

JoCat commented Dec 3, 2024

I tried to reproduce this problem again and I think I have figured out the cause. If you don't use ValidationPipe globally with transform: true specified, everything works correctly.

https://codesandbox.io/p/devbox/intelligent-zeh-mkyzmh

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.

3 participants