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: handle PydanticSerializationError that generates generic errors in the UI #3108

Merged
merged 9 commits into from
Jul 31, 2024

Conversation

ogabrielluiz
Copy link
Contributor

This pull request fixes the handling of PydanticSerializationError in the JavaScriptMIMETypeMiddleware. Previously, when a serialization error occurred, a generic error message was returned. With this fix, a more detailed error message is provided. This ensures that users can easily identify and troubleshoot serialization errors.

ogabrielluiz and others added 6 commits July 31, 2024 09:11
…Middleware to provide detailed error message in case of serialization error
…Middleware to provide detailed error message in case of serialization error
Refactor the `JavaScriptMIMETypeMiddleware` class in `main.py` to handle the `PydanticSerializationError` exception. This change ensures that a detailed error message is provided in case of a serialization error. The error message is now serialized as a JSON string and included in the `detail` field of the `HTTPException` raised.
This commit adds a new function called `tryParseJson` to the `utils.ts` file. The function attempts to parse a JSON string and returns the parsed object. If parsing fails, it returns undefined. This function can be used to safely parse JSON strings without throwing an error.
This commit modifies the buildVertex function in buildUtils.ts to handle error messages more effectively. It adds logic to extract the error message from the AxiosError response and parse it as JSON if possible. If the error message is not an array, it converts it into an array. This change ensures that the error message is properly displayed when building a component fails.
@ogabrielluiz ogabrielluiz enabled auto-merge (squash) July 31, 2024 12:53
@ogabrielluiz ogabrielluiz requested a review from anovazzi1 July 31, 2024 12:53
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working javascript Pull requests that update Javascript code labels Jul 31, 2024
Copy link
Contributor

Pull Request Validation Report

This comment is automatically generated by Conventional PR

Whitelist Report

Whitelist Active Result
Pull request is a draft and should be ignored
Pull request is made by a whitelisted user and should be ignored
Pull request is submitted by a bot and should be ignored
Pull request is submitted by administrators and should be ignored

Result

Pull request does not satisfy any enabled whitelist criteria. Pull request will be validated.

Validation Report

Validation Active Result
All commits in this pull request has valid messages
Pull request does not introduce too many changes
Pull request has a valid title
Pull request has mentioned issues
Pull request has valid branch name
Pull request should have a non-empty body

Result

Pull request satisfies all enabled pull request rules.

Last Modified at 31 Jul 24 12:57 UTC

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-3108.dmtpw4p5recq1.amplifyapp.com

@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jul 31, 2024
Copy link
Contributor

@anovazzi1 anovazzi1 left a comment

Choose a reason for hiding this comment

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

lgtm

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 31, 2024
@ogabrielluiz ogabrielluiz changed the title fix: handle PydanticSerializationError in JavaScriptMIMETypeMiddleware fix: handle PydanticSerializationError that causes unknown errors Jul 31, 2024
@ogabrielluiz ogabrielluiz changed the title fix: handle PydanticSerializationError that causes unknown errors fix: handle PydanticSerializationError that causes unknown errors in the UI Jul 31, 2024
@ogabrielluiz ogabrielluiz changed the title fix: handle PydanticSerializationError that causes unknown errors in the UI fix: handle PydanticSerializationError that generates generic errors in the UI Jul 31, 2024
@ogabrielluiz ogabrielluiz removed the javascript Pull requests that update Javascript code label Jul 31, 2024
@ogabrielluiz ogabrielluiz merged commit f08467d into main Jul 31, 2024
54 checks passed
@ogabrielluiz ogabrielluiz deleted the fix/exceptionhandling branch July 31, 2024 18:23
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jul 31, 2024
nicoloboschi pushed a commit to datastax/ragstack-ai-langflow that referenced this pull request Aug 1, 2024
…in the UI (langflow-ai#3108)

* fix(main.py): handle PydanticSerializationError in JavaScriptMIMETypeMiddleware to provide detailed error message in case of serialization error

* fix(main.py): handle PydanticSerializationError in JavaScriptMIMETypeMiddleware to provide detailed error message in case of serialization error

* improve error handling

* feat: Handle PydanticSerializationError in JavaScriptMIMETypeMiddleware

Refactor the `JavaScriptMIMETypeMiddleware` class in `main.py` to handle the `PydanticSerializationError` exception. This change ensures that a detailed error message is provided in case of a serialization error. The error message is now serialized as a JSON string and included in the `detail` field of the `HTTPException` raised.

* feat: Add tryParseJson function to utils.ts

This commit adds a new function called `tryParseJson` to the `utils.ts` file. The function attempts to parse a JSON string and returns the parsed object. If parsing fails, it returns undefined. This function can be used to safely parse JSON strings without throwing an error.

* fix: Handle error message in buildVertex function

This commit modifies the buildVertex function in buildUtils.ts to handle error messages more effectively. It adds logic to extract the error message from the AxiosError response and parse it as JSON if possible. If the error message is not an array, it converts it into an array. This change ensures that the error message is properly displayed when building a component fails.

* remove console.log

* remove not related code

---------

Co-authored-by: anovazzi1 <otavio2204@gmail.com>
(cherry picked from commit f08467d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants