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: wrap parsing with try catch statements #1321

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Conversation

mamadoudicko
Copy link
Contributor

No description provided.

@mamadoudicko mamadoudicko temporarily deployed to preview October 4, 2023 09:20 — with GitHub Actions Inactive
@dosubot dosubot bot added the area: frontend Related to frontend functionality or under the /frontend directory label Oct 4, 2023
@vercel
Copy link

vercel bot commented Oct 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2023 9:25am
quivr-strapi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2023 9:25am
quivrapp ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2023 9:25am

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2023

Risk Level 2 - /home/runner/work/quivr/quivr/frontend/app/chat/[chatId]/components/ChatDialogueArea/components/ChatDialogue/components/ChatNotification/components/NotificationDisplayer/NotificationDisplayer.tsx

The code seems to be well written and follows the SOLID principles. However, there are a few areas that could be improved for better readability and error handling:

  1. Error Handling: In the try-catch block, the error is caught but not handled or logged. This could make debugging difficult if the JSON.parse operation fails. Consider logging the error or handling it appropriately.
    try {
      const parsedMessage = JSON.parse(nonParsedMessage) as NotificationMessage;
      message = parsedMessage.message;
      status = parsedMessage.status;
      name = parsedMessage.name;
    } catch (error) {
      console.error(error);
      return <Fragment />;
    }
  2. Nullish Coalescing: Instead of checking for null or undefined with nonParsedMessage === null || nonParsedMessage === undefined, consider using the nullish coalescing operator (??) for cleaner code.
    const nonParsedMessage = content.message ?? <Fragment />;
  3. Type Safety: The nonParsedMessage is directly parsed without any type checking. If the nonParsedMessage is not a valid JSON string, it will throw an error. Consider adding a type check before parsing.
    if (typeof nonParsedMessage === 'string') {
      const parsedMessage = JSON.parse(nonParsedMessage) as NotificationMessage;
      // ...
    }

🐛🔍👍


Powered by Code Review GPT

@mamadoudicko mamadoudicko merged commit bf5b755 into main Oct 4, 2023
7 checks passed
gozineb pushed a commit that referenced this pull request Oct 5, 2023
🤖 I have created a release *beep* *boop*
---


## 0.0.88 (2023-10-05)

## What's Changed
* fix: wrap parsing with try catch statements by @mamadoudicko in
#1321
* fix: 🐛 ↕️ 📱height now matches mobile height by @matthieujacq in
#1323
* feat: add onboarding step 3 by @mamadoudicko in
#1324
* feat: restructure the sidebar of the brains management page by
@matthieujacq in #1325
* feat: add onboarding table by @mamadoudicko in
#1327
* feat: update onboarding controller and fix typo by @mamadoudicko in
#1333


**Full Changelog**:
v0.0.87...v0.0.88

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
coolCatalyst added a commit to coolCatalyst/quivr that referenced this pull request Jun 1, 2024
🤖 I have created a release *beep* *boop*
---


## 0.0.88 (2023-10-05)

## What's Changed
* fix: wrap parsing with try catch statements by @mamadoudicko in
QuivrHQ/quivr#1321
* fix: 🐛 ↕️ 📱height now matches mobile height by @matthieujacq in
QuivrHQ/quivr#1323
* feat: add onboarding step 3 by @mamadoudicko in
QuivrHQ/quivr#1324
* feat: restructure the sidebar of the brains management page by
@matthieujacq in QuivrHQ/quivr#1325
* feat: add onboarding table by @mamadoudicko in
QuivrHQ/quivr#1327
* feat: update onboarding controller and fix typo by @mamadoudicko in
QuivrHQ/quivr#1333


**Full Changelog**:
QuivrHQ/quivr@v0.0.87...v0.0.88

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: frontend Related to frontend functionality or under the /frontend directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants