Skip to content

Fix: Prevent app crash when external CSV is empty in ThankYouNote #565

Open
madhuri-perumalla wants to merge 2 commits intojenkins-infra:mainfrom
madhuri-perumalla:fix/csv-crash-thankyou
Open

Fix: Prevent app crash when external CSV is empty in ThankYouNote #565
madhuri-perumalla wants to merge 2 commits intojenkins-infra:mainfrom
madhuri-perumalla:fix/csv-crash-thankyou

Conversation

@madhuri-perumalla
Copy link
Copy Markdown
Contributor

Problem

The ThankYouNote component was directly accessing parsed CSV data without checking if it exists:

    setThankYou(Papa.parse(response.data)?.data[1]);

----> If the CSV is empty or only contains headers, data[1] becomes undefined.
----> This later causes runtime errors when the code tries to access values like undefined[6].

Fixes

Added a validation step to ensure the parsed data exists and contains at least one data row before setting the state:

    const parsedData = Papa.parse(response.data);

    if (Array.isArray(parsedData?.data) && parsedData.data.length > 1) {
        setThankYou(parsedData.data[1]);
    }

Result

  ✔ Prevents crashes when the CSV is empty or malformed
  ✔ Ensures the component only uses valid data
  ✔ Keeps the UI stable even when external data is missing

@madhuri-perumalla madhuri-perumalla requested a review from a team as a code owner March 20, 2026 08:04
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.

2 participants