Skip to content

Conversation

@Khushboo1324
Copy link

@Khushboo1324 Khushboo1324 commented Dec 28, 2025

Summary

This PR improves error handling in the NewsletterSubscribe component by
distinguishing service outages from generic failures.

What Changed

  • Added a SERVICE_UNAVAILABLE status to the form state
  • Improved fetch response handling to detect backend failures
  • Displayed a clearer message when the newsletter service is unavailable
  • Kept existing error UI for other failure cases

Related Issues

Fixes #4643
Related to #4686

Summary by CodeRabbit

  • New Features

    • Added a dedicated "service unavailable" state and user-facing message for temporary outages, prompting users to retry later.
  • Bug Fixes

    • Improved handling of server and network failures to surface clearer feedback and preserve existing success/error flows.
    • Adjusted UI state logic for more consistent rendering during submission and error conditions.

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link

netlify bot commented Dec 28, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 67f1c6a
🔍 Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/695cd04ad659480008ac067c
😎 Deploy Preview https://deploy-preview-4798--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

📝 Walkthrough

Walkthrough

Adds a new FormStatus member SERVICE_UNAVAILABLE, updates submit handling to map 200 → SUCCESS, 503 → SERVICE_UNAVAILABLE, other codes → ERROR, and network failures → SERVICE_UNAVAILABLE; adds a dedicated UI branch for the new status, replaces string status checks with enum comparisons, and removes a legacy doc block.

Changes

Cohort / File(s) Summary
Newsletter subscribe component
components/NewsletterSubscribe.tsx
Added FormStatus.SERVICE_UNAVAILABLE; updated handleSubmit fetch flow to map 200→SUCCESS, 503→SERVICE_UNAVAILABLE, others→ERROR and set SERVICE_UNAVAILABLE on network failures; introduced UI branch for SERVICE_UNAVAILABLE; swapped string literal status checks for enum comparisons; removed legacy comment block; minor formatting/JSX adjustments.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User (Browser)
  participant C as NewsletterSubscribe Component
  participant S as Newsletter API (Server)

  U->>C: submit form (name, email)
  C->>S: fetch POST /subscribe
  alt 200 OK
    S-->>C: 200 + success body
    C->>C: set FormStatus.SUCCESS
    Note right of C: render success message
  else 503 Service Unavailable
    S-->>C: 503
    C->>C: set FormStatus.SERVICE_UNAVAILABLE
    Note right of C: render temporary unavailability message
  else other error status
    S-->>C: other status
    C->>C: set FormStatus.ERROR
    Note right of C: render generic error message
  end
  opt Network failure / fetch reject
    C-->>C: catch -> set FormStatus.SERVICE_UNAVAILABLE
    Note right of C: render temporary unavailability message
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐇 I hopped the form and pressed submit,
The server sighed, then took a quick knit.
If 503 makes the garden hush,
I tuck a note and skip the rush.
Come back later — I'll keep your bit! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: improving newsletter subscription error handling for service outages, which directly aligns with the changeset's core objective.
Linked Issues check ✅ Passed The PR successfully addresses issue #4643 by replacing generic failure messages with specific error handling that distinguishes service outages and network failures, providing clearer messaging.
Out of Scope Changes check ✅ Passed All changes are directly related to improving newsletter error handling: the SERVICE_UNAVAILABLE status, enhanced fetch response handling, and UI improvements for service outages are in scope.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances error handling in the NewsletterSubscribe component to provide better user feedback during service outages and network failures. It introduces a new SERVICE_UNAVAILABLE form status and updates the fetch error handling logic to distinguish between different failure scenarios.

Key changes:

  • Added SERVICE_UNAVAILABLE status to the FormStatus enum and corresponding UI rendering
  • Implemented explicit handling for 401 responses and network failures by mapping them to the service unavailable state
  • Improved JSON parsing safety with try-catch to handle malformed responses
  • Code formatting improvements (single to double quotes, consistent enum usage)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.then(async (res) => {
if (res.status === 200) {
setFormStatus(FormStatus.SUCCESS);
} else if (res.status === 401) {
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

A 401 Unauthorized status typically indicates authentication/authorization issues, not service unavailability. The PR description mentions handling service outages, but 401 is not the appropriate status code for this. Consider using 503 Service Unavailable instead, or handle 401 separately as an authentication error.

Suggested change
} else if (res.status === 401) {
} else if (res.status === 503) {

Copilot uses AI. Check for mistakes.
Comment on lines 130 to 133
Newsletter service temporarily unavailable
</Heading>
<Paragraph className="mb-8" textColor={paragraphTextColor}>
Please try again later.
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The new SERVICE_UNAVAILABLE state does not use internationalization (i18n) for its messages, unlike the SUCCESS and ERROR states which use the translation hook. The hardcoded strings "Newsletter service temporarily unavailable" and "Please try again later." should be added to the translation files and retrieved using the t() function for consistency with the rest of the component.

Suggested change
Newsletter service temporarily unavailable
</Heading>
<Paragraph className="mb-8" textColor={paragraphTextColor}>
Please try again later.
{ready
? t('serviceUnavailableTitle')
: 'Newsletter service temporarily unavailable'}
</Heading>
<Paragraph className="mb-8" textColor={paragraphTextColor}>
{ready ? t('serviceUnavailableSubtitle') : 'Please try again later.'}

Copilot uses AI. Check for mistakes.
@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Dec 28, 2025

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 36
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-4798--asyncapi-website.netlify.app/

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
components/NewsletterSubscribe.tsx (2)

140-159: Fix quote style to pass linting.

Multiple lines have double quotes that should be single quotes per the project's Prettier configuration.

🔎 Proposed fix
   if (status === FormStatus.ERROR) {
     return (
-      <div className={className} data-testid="NewsletterSubscribe-main">
+      <div className={className} data-testid='NewsletterSubscribe-main'>
         <Heading
           level={HeadingLevel.h3}
           textColor={headTextColor}
           typeStyle={HeadingTypeStyle.lg}
-          className="mb-4"
+          className='mb-4'
         >
           {ready ? t('errorTitle') : 'Something went wrong'}
         </Heading>
-        <Paragraph className="mb-8" textColor={paragraphTextColor}>
+        <Paragraph className='mb-8' textColor={paragraphTextColor}>
           {ready ? t('errorSubtitle') : errorSubtitle}{' '}
           <TextLink
-            href="https://github.com/asyncapi/website/issues/new?template=bug.md"
-            target="_blank"
+            href='https://github.com/asyncapi/website/issues/new?template=bug.md'
+            target='_blank'
           >
             {ready ? t('errorLinkText') : 'here'}
           </TextLink>

163-209: Fix quote style and review empty href.

Multiple lines have double quotes that should be single quotes. Additionally, line 204 has an empty href attribute on a submit button, which seems unnecessary.

🔎 Proposed fix for quote style
   return (
-    <div className={className} data-testid="NewsletterSubscribe-main">
+    <div className={className} data-testid='NewsletterSubscribe-main'>
       <Heading
         level={HeadingLevel.h3}
         textColor={headTextColor}
         typeStyle={HeadingTypeStyle.lg}
-        className="mb-4"
+        className='mb-4'
       >
         {ready ? t('title') : title}
       </Heading>
-      <Paragraph className="mb-8" textColor={paragraphTextColor}>
+      <Paragraph className='mb-8' textColor={paragraphTextColor}>
         {ready ? t('subtitle') : subtitle}
       </Paragraph>
       {status === FormStatus.LOADING ? (
         <Loader
-          loaderText={'Waiting for response...'}
+          loaderText='Waiting for response...'
           loaderIcon={<IconCircularLoader dark />}
           dark={dark}
         />
       ) : (
         <form
-          className="flex flex-col gap-4 md:flex-row"
+          className='flex flex-col gap-4 md:flex-row'
           onSubmit={handleSubmit}
         >
           <InputBox
             inputType={InputTypes.TEXT}
-            inputName="name"
+            inputName='name'
             placeholder={ready ? t('nameInput') : 'Your name'}
             inputValue={name}
             setInput={setName}
           />
           <InputBox
             inputType={InputTypes.EMAIL}
-            inputName="email"
+            inputName='email'
             placeholder={ready ? t('emailInput') : 'Your email'}
             inputValue={email}
             setInput={setEmail}
           />
           <Button
             type={ButtonType.SUBMIT}
             text={ready ? t('subscribeBtn') : 'Subscribe'}
-            className="mt-2 w-full md:mr-2 md:mt-0 md:flex-1"
-            href=""
+            className='mt-2 w-full md:mr-2 md:mt-0 md:flex-1'
+            href=''
           />
💡 Optional: Consider removing the empty href

The Button component has type={ButtonType.SUBMIT}, which makes it a submit button. The empty href='' attribute appears unnecessary. Consider checking if the Button component requires an href prop or if it can be omitted for submit buttons:

           <Button
             type={ButtonType.SUBMIT}
             text={ready ? t('subscribeBtn') : 'Subscribe'}
             className='mt-2 w-full md:mr-2 md:mt-0 md:flex-1'
-            href=''
           />
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 785c358 and 64ae37e.

📒 Files selected for processing (1)
  • components/NewsletterSubscribe.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
components/NewsletterSubscribe.tsx (7)
components/typography/Heading.tsx (1)
  • Heading (30-85)
components/typography/Paragraph.tsx (1)
  • Paragraph (28-56)
components/typography/TextLink.tsx (1)
  • TextLink (21-42)
components/Loader.tsx (1)
  • Loader (28-41)
components/icons/CircularLoader.tsx (1)
  • IconCircularLoader (13-20)
components/InputBox.tsx (1)
  • InputBox (8-21)
components/buttons/Button.tsx (1)
  • Button (53-106)
🪛 GitHub Actions: PR testing - if Node project
components/NewsletterSubscribe.tsx

[error] 50-50: prettier/prettier: Delete , and trailing comma.


[error] 74-74: prettier/prettier: Delete , and trailing comma.


[error] 81-81: prettier/prettier: Delete , and trailing comma.


[error] 82-82: prettier/prettier: Delete , and trailing comma.


[error] 106-106: prettier/prettier: Replace "NewsletterSubscribe-main" with 'NewsletterSubscribe-main' and jsx-quotes.


[error] 107-107: jsx-quotes: Unexpected usage of doublequote.


[error] 111-111: prettier/prettier: Unexpected usage of doublequote.


[error] 115-115: prettier/prettier: Replace "mb-8" with 'mb-8'.


[error] 123-123: prettier/prettier: Replace "NewsletterSubscribe-main" with 'NewsletterSubscribe-main' and jsx-quotes.


[error] 124-124: jsx-quotes: Unexpected usage of doublequote.


[error] 128-128: prettier/prettier: Unexpected usage of doublequote.


[error] 132-132: prettier/prettier: Replace "mb-8" with 'mb-8' and jsx-quotes.


[error] 140-140: prettier/prettier: Replace "NewsletterSubscribe-main" with 'NewsletterSubscribe-main' and jsx-quotes.


[error] 145-145: prettier/prettier: Unexpected usage of doublequote.


[error] 149-149: prettier/prettier: Replace "mb-8" with 'mb-8'.


[error] 151-151: prettier/prettier: Unexpected usage of doublequote.


[error] 163-163: prettier/prettier: Replace "NewsletterSubscribe-main" with 'NewsletterSubscribe-main' and jsx-quotes.


[error] 164-164: jsx-quotes: Unexpected usage of doublequote.


[error] 168-168: prettier/prettier: Unexpected usage of doublequote.


[error] 172-172: prettier/prettier: Replace "mb-8" with 'mb-8'.


[error] 176-176: prettier/prettier: Unexpected usage of doublequote.


[error] 182-182: prettier/prettier: Replace "flex flex-col gap-4 md:flex-row" with 'flex flex-col gap-4 md:flex-row' and onSubmit prop formatting.


[error] 183-183: jsx-quotes: Unexpected usage of doublequote.


[error] 188-188: prettier/prettier: Replace "name" with 'name' and jsx-quotes.


[error] 195-195: prettier/prettier: Replace "email" with 'email' and jsx-quotes.


[error] 203-203: prettier/prettier: Replace "mt-2 w-full md:mr-2 md:mt-0 md:flex-1" with 'mt-2 w-full md:mr-2 md:mt-0 md:flex-1' and jsx-quotes.


[error] 204-204: prettier/prettier: Empty string should be '' not "".

⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Lighthouse CI
🔇 Additional comments (4)
components/NewsletterSubscribe.tsx (4)

20-21: LGTM! Clean enum extension.

The new SERVICE_UNAVAILABLE status value is well-named and appropriately added to the FormStatus enum.


93-97: LGTM! Good defensive programming.

The try-catch around res.json() with a null fallback gracefully handles malformed JSON responses and prevents unhandled promise rejections.


99-101: LGTM! Appropriate network failure handling.

Mapping network failures to SERVICE_UNAVAILABLE is appropriate and provides a better user experience than a generic error message.


84-91: The 401 → SERVICE_UNAVAILABLE mapping is semantically incorrect.

HTTP 401 (Unauthorized) indicates authentication/authorization failure—typically a configuration issue like an invalid API key—not a temporary service outage. HTTP 503 is the standard status for "Service Unavailable." The user-facing message "Please try again later" implies a temporary condition, but 401 represents a persistent configuration problem.

While the PR objectives mention handling 401 explicitly, this mapping misleads users into thinking a temporary issue will resolve itself when the actual problem is likely a misconfigured API key.

Recommend either:

  • Mapping 401 to ERROR (authentication failure) instead
  • Only mapping 503 responses to SERVICE_UNAVAILABLE
  • Adding clear documentation explaining why 401 is treated as a service outage

Comment on lines 121 to 137
if (status === FormStatus.SERVICE_UNAVAILABLE) {
return (
<div className={className} data-testid="NewsletterSubscribe-main">
<Heading
level={HeadingLevel.h3}
textColor={headTextColor}
typeStyle={HeadingTypeStyle.lg}
className="mb-4"
>
Newsletter service temporarily unavailable
</Heading>
<Paragraph className="mb-8" textColor={paragraphTextColor}>
Please try again later.
</Paragraph>
</div>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix quote style and consider internationalization.

Multiple lines have double quotes that should be single quotes. Additionally, unlike other states, this message is not internationalized using the ready check and t() function.

🔎 Proposed fix for quote style
   if (status === FormStatus.SERVICE_UNAVAILABLE) {
     return (
-      <div className={className} data-testid="NewsletterSubscribe-main">
+      <div className={className} data-testid='NewsletterSubscribe-main'>
         <Heading
           level={HeadingLevel.h3}
           textColor={headTextColor}
           typeStyle={HeadingTypeStyle.lg}
-          className="mb-4"
+          className='mb-4'
         >
           Newsletter service temporarily unavailable
         </Heading>
-        <Paragraph className="mb-8" textColor={paragraphTextColor}>
+        <Paragraph className='mb-8' textColor={paragraphTextColor}>
           Please try again later.
         </Paragraph>
       </div>
💡 Optional: Add i18n support

To maintain consistency with other states, consider adding translation keys for the SERVICE_UNAVAILABLE messages in your translation files and using them with the ready check:

         >
-          Newsletter service temporarily unavailable
+          {ready ? t('serviceUnavailableTitle') : 'Newsletter service temporarily unavailable'}
         </Heading>
-        <Paragraph className='mb-8' textColor={paragraphTextColor}>
-          Please try again later.
+        <Paragraph className='mb-8' textColor={paragraphTextColor}>
+          {ready ? t('serviceUnavailableSubtitle') : 'Please try again later.'}
         </Paragraph>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (status === FormStatus.SERVICE_UNAVAILABLE) {
return (
<div className={className} data-testid="NewsletterSubscribe-main">
<Heading
level={HeadingLevel.h3}
textColor={headTextColor}
typeStyle={HeadingTypeStyle.lg}
className="mb-4"
>
Newsletter service temporarily unavailable
</Heading>
<Paragraph className="mb-8" textColor={paragraphTextColor}>
Please try again later.
</Paragraph>
</div>
);
}
if (status === FormStatus.SERVICE_UNAVAILABLE) {
return (
<div className={className} data-testid='NewsletterSubscribe-main'>
<Heading
level={HeadingLevel.h3}
textColor={headTextColor}
typeStyle={HeadingTypeStyle.lg}
className='mb-4'
>
Newsletter service temporarily unavailable
</Heading>
<Paragraph className='mb-8' textColor={paragraphTextColor}>
Please try again later.
</Paragraph>
</div>
);
}
🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[error] 123-123: prettier/prettier: Replace "NewsletterSubscribe-main" with 'NewsletterSubscribe-main' and jsx-quotes.


[error] 124-124: jsx-quotes: Unexpected usage of doublequote.


[error] 128-128: prettier/prettier: Unexpected usage of doublequote.


[error] 132-132: prettier/prettier: Replace "mb-8" with 'mb-8' and jsx-quotes.

🤖 Prompt for AI Agents
In components/NewsletterSubscribe.tsx around lines 121-137, the
SERVICE_UNAVAILABLE block uses double quotes and hard-coded English strings;
change string literals to single quotes to match project style and replace the
hard-coded Heading/Paragraph text with i18n lookups using the existing ready
check and t() function (add/consume translation keys like
newsletter.serviceUnavailable.title and newsletter.serviceUnavailable.message),
ensuring you only render translated text when ready to avoid SSR issues.

@Khushboo1324 Khushboo1324 changed the title Improve newsletter subscription error handling for service outages fix: Improve newsletter subscription error handling for service outages Dec 28, 2025
@Khushboo1324 Khushboo1324 requested a review from Copilot December 28, 2025 13:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +99 to +101
.catch(() => {
setFormStatus(FormStatus.SERVICE_UNAVAILABLE);
});
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The catch block will catch network errors and fetch failures, but will also catch any errors thrown in the preceding then block. If the JSON parsing fails or if there's an error in setFormStatus, this will incorrectly set the status to SERVICE_UNAVAILABLE. Consider handling network errors separately or ensuring the catch only handles the specific error types it's intended for.

Copilot uses AI. Check for mistakes.
Comment on lines 94 to 96
return await res.json();
} catch {
return null;
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

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

The parsed JSON response is returned but never used or stored anywhere. This return value from the promise chain has no effect since there's no variable assignment or further then() handler. Consider either removing the return statement and JSON parsing if the response body isn't needed, or storing it for potential future use or logging.

Suggested change
return await res.json();
} catch {
return null;
await res.json();
} catch {
// Response body is ignored

Copilot uses AI. Check for mistakes.
@Khushboo1324 Khushboo1324 changed the title fix: Improve newsletter subscription error handling for service outages fix: improve newsletter subscription error handling for service outages Dec 28, 2025
@Khushboo1324
Copy link
Author

Hi maintainers ,
I’ve updated the PR title to follow conventional commits.
The failing checks seem to be due to workflows awaiting approval.
Happy to make any further changes if needed. Thanks!

@princerajpoot20
Copy link
Member

@Khushboo1324 Please have a look at the failed workflow. It is failing because of your changes. You can analyze the run to understand it better. let me know you still need more help

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (785c358) to head (67f1c6a).
⚠️ Report is 17 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #4798   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines          798       796    -2     
  Branches       146       146           
=========================================
- Hits           798       796    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI Agents
In @components/NewsletterSubscribe.tsx:
- Around line 77-78: The branch that treats HTTP 401 as service unavailability
is incorrect: change the check on res.status from 401 to 503 and
setFormStatus(FormStatus.SERVICE_UNAVAILABLE) when res.status === 503;
additionally, if you need to handle authentication issues, add a separate branch
for res.status === 401 (e.g., setFormStatus(FormStatus.AUTH_ERROR) or another
appropriate enum member) so authentication and service outages are mapped to
distinct FormStatus values; update any conditional logic in
NewsletterSubscribe.tsx that references res.status, setFormStatus, and the
FormStatus enum accordingly.
- Around line 83-91: The catch currently catches JSON parse errors from
res.json() and treats them as network failures; in the NewsletterSubscribe
component change the fetch then-chain so you call
setFormStatus(FormStatus.SERVICE_UNAVAILABLE) (or handle response status) before
attempting res.json(), or remove the res.json() entirely if the body isn’t used;
ensure res.json() parsing happens in a separate try/catch so JSON errors are
handled separately and do not trigger the network-error handler tied to
setFormStatus(FormStatus.SERVICE_UNAVAILABLE).
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 64ae37e and 8753514.

📒 Files selected for processing (1)
  • components/NewsletterSubscribe.tsx
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-03-16T15:55:44.257Z
Learnt from: JeelRajodiya
Repo: asyncapi/website PR: 3423
File: scripts/index.ts:29-31
Timestamp: 2025-03-16T15:55:44.257Z
Learning: In the AsyncAPI codebase, adding try-catch blocks around function calls is unnecessary when the only purpose is to add context to the error message, as errors will be thrown from the functions themselves with full stack traces that provide adequate context. Try-catch blocks should only be added when there's a need for graceful degradation, partial success behavior, or specific error handling logic.

Applied to files:

  • components/NewsletterSubscribe.tsx
📚 Learning: 2024-12-31T09:25:52.573Z
Learnt from: JeelRajodiya
Repo: asyncapi/website PR: 3423
File: scripts/adopters/index.ts:9-11
Timestamp: 2024-12-31T09:25:52.573Z
Learning: The `writeJSON` function already includes error handling, so additional try/catch blocks around it may be redundant.

Applied to files:

  • components/NewsletterSubscribe.tsx
📚 Learning: 2025-12-29T14:21:28.216Z
Learnt from: sammy200-ui
Repo: asyncapi/website PR: 4804
File: components/navigation/Filter.tsx:32-41
Timestamp: 2025-12-29T14:21:28.216Z
Learning: In the asyncapi/website repository, when you intentionally omit dependencies in React hooks (e.g., useEffect, useMemo), add an eslint-disable comment with an explanatory note above the line to justify the design choice. For example: // eslint-disable-next-line react-hooks/exhaustive-deps: intentionally omitting dependencies to avoid unnecessary re-runs. This helps reviewers understand the rationale and keeps lint guidance informative.

Applied to files:

  • components/NewsletterSubscribe.tsx
🧬 Code graph analysis (1)
components/NewsletterSubscribe.tsx (2)
components/typography/Heading.tsx (1)
  • Heading (30-85)
components/typography/Paragraph.tsx (1)
  • Paragraph (28-56)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: Test NodeJS PR - windows-latest
🔇 Additional comments (2)
components/NewsletterSubscribe.tsx (2)

20-21: LGTM: SERVICE_UNAVAILABLE status added correctly.

The new enum member follows the existing pattern and provides a distinct state for service outages.


144-144: LGTM: Consistent enum-based status check.

Switching from a string literal to FormStatus.LOADING improves type safety and consistency with the rest of the refactored code.

Comment on lines 77 to 78
} else if (res.status === 401) {
setFormStatus(FormStatus.SERVICE_UNAVAILABLE);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use HTTP 503 for service unavailability, not 401.

HTTP 401 indicates authentication/authorization errors, not service outages. For service unavailability, the standard status code is 503. Mapping 401 to SERVICE_UNAVAILABLE creates a semantic mismatch and may confuse users with incorrect messaging.

🔎 Proposed fix
-        } else if (res.status === 401) {
+        } else if (res.status === 503) {
           setFormStatus(FormStatus.SERVICE_UNAVAILABLE);

If you need to handle both 503 and authentication errors separately:

         if (res.status === 200) {
           setFormStatus(FormStatus.SUCCESS);
+        } else if (res.status === 503) {
+          setFormStatus(FormStatus.SERVICE_UNAVAILABLE);
-        } else if (res.status === 401) {
-          setFormStatus(FormStatus.SERVICE_UNAVAILABLE);
         } else {
           setFormStatus(FormStatus.ERROR);
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else if (res.status === 401) {
setFormStatus(FormStatus.SERVICE_UNAVAILABLE);
} else if (res.status === 503) {
setFormStatus(FormStatus.SERVICE_UNAVAILABLE);
🤖 Prompt for AI Agents
In @components/NewsletterSubscribe.tsx around lines 77 - 78, The branch that
treats HTTP 401 as service unavailability is incorrect: change the check on
res.status from 401 to 503 and setFormStatus(FormStatus.SERVICE_UNAVAILABLE)
when res.status === 503; additionally, if you need to handle authentication
issues, add a separate branch for res.status === 401 (e.g.,
setFormStatus(FormStatus.AUTH_ERROR) or another appropriate enum member) so
authentication and service outages are mapped to distinct FormStatus values;
update any conditional logic in NewsletterSubscribe.tsx that references
res.status, setFormStatus, and the FormStatus enum accordingly.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
components/NewsletterSubscribe.tsx (1)

74-85: Remove unnecessary async keyword.

The callback is marked async but contains no await expressions. Since JSON parsing was removed, the async modifier serves no purpose.

🔎 Proposed fix
-      .then(async (res) => {
+      .then((res) => {
         if (res.status === 200) {
           setFormStatus(FormStatus.SUCCESS);
         } else if (res.status === 503) {
           setFormStatus(FormStatus.SERVICE_UNAVAILABLE);
         } else {
           setFormStatus(FormStatus.ERROR);
         }
       })
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8753514 and 67f1c6a.

📒 Files selected for processing (1)
  • components/NewsletterSubscribe.tsx
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-03-16T15:55:44.257Z
Learnt from: JeelRajodiya
Repo: asyncapi/website PR: 3423
File: scripts/index.ts:29-31
Timestamp: 2025-03-16T15:55:44.257Z
Learning: In the AsyncAPI codebase, adding try-catch blocks around function calls is unnecessary when the only purpose is to add context to the error message, as errors will be thrown from the functions themselves with full stack traces that provide adequate context. Try-catch blocks should only be added when there's a need for graceful degradation, partial success behavior, or specific error handling logic.

Applied to files:

  • components/NewsletterSubscribe.tsx
📚 Learning: 2024-12-31T09:25:52.573Z
Learnt from: JeelRajodiya
Repo: asyncapi/website PR: 3423
File: scripts/adopters/index.ts:9-11
Timestamp: 2024-12-31T09:25:52.573Z
Learning: The `writeJSON` function already includes error handling, so additional try/catch blocks around it may be redundant.

Applied to files:

  • components/NewsletterSubscribe.tsx
📚 Learning: 2025-12-29T14:21:28.216Z
Learnt from: sammy200-ui
Repo: asyncapi/website PR: 4804
File: components/navigation/Filter.tsx:32-41
Timestamp: 2025-12-29T14:21:28.216Z
Learning: In the asyncapi/website repository, when you intentionally omit dependencies in React hooks (e.g., useEffect, useMemo), add an eslint-disable comment with an explanatory note above the line to justify the design choice. For example: // eslint-disable-next-line react-hooks/exhaustive-deps: intentionally omitting dependencies to avoid unnecessary re-runs. This helps reviewers understand the rationale and keeps lint guidance informative.

Applied to files:

  • components/NewsletterSubscribe.tsx
🧬 Code graph analysis (1)
components/NewsletterSubscribe.tsx (2)
components/typography/Heading.tsx (1)
  • Heading (30-85)
components/typography/Paragraph.tsx (1)
  • Paragraph (28-56)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: Test NodeJS PR - windows-latest
🔇 Additional comments (2)
components/NewsletterSubscribe.tsx (2)

16-22: LGTM!

The SERVICE_UNAVAILABLE enum member follows the existing naming convention and is correctly placed within the FormStatus enum.


138-138: LGTM!

Using enum-based comparison (FormStatus.LOADING) instead of string literals improves type safety and consistency with the other status checks.

@Khushboo1324
Copy link
Author

I’ve addressed the lint, semantics and formatting issues causing the CI failure
All checks are now passing locally and in CI.
Please let me know if anything else needs adjustment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Newsletter sign-up form failing

3 participants