Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Oct 9, 2025


PR-Codex overview

This PR focuses on enhancing error handling in the useCsvUpload hook by introducing a try-catch block to manage potential parsing errors and improve the flow when the parsed data lacks an address field.

Detailed summary

  • Wrapped the data parsing logic in a try-catch block to handle errors gracefully.
  • Added a check for data[0]?.address to set noCsv to true if the address is missing and return early.
  • Removed the previous unconditional setting of rawData outside the try block.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Bug Fixes
    • Prevents crashes during CSV uploads by handling parse errors gracefully.
    • Ensures malformed or missing-address CSVs are detected and flagged without updating data.
    • Only updates uploaded data when required fields are present.
    • Improves reliability of the upload flow with clearer invalid-file handling and explicit error handling.

@linear
Copy link

linear bot commented Oct 9, 2025

@vercel vercel bot temporarily deployed to Preview – nebula October 9, 2025 16:36 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 October 9, 2025 16:36 Inactive
@vercel
Copy link

vercel bot commented Oct 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
thirdweb-www Ready Ready Preview Comment Oct 9, 2025 6:40pm
4 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs-v2 Skipped Skipped Oct 9, 2025 6:40pm
nebula Skipped Skipped Oct 9, 2025 6:40pm
thirdweb_playground Skipped Skipped Oct 9, 2025 6:40pm
wallet-ui Skipped Skipped Oct 9, 2025 6:40pm

@vercel vercel bot temporarily deployed to Preview – wallet-ui October 9, 2025 16:36 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground October 9, 2025 16:36 Inactive
@changeset-bot
Copy link

changeset-bot bot commented Oct 9, 2025

⚠️ No Changeset found

Latest commit: fe940b3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@MananTank MananTank marked this pull request as ready for review October 9, 2025 16:36
@MananTank MananTank requested review from a team as code owners October 9, 2025 16:36
@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Oct 9, 2025
Copy link
Member Author

MananTank commented Oct 9, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

Walkthrough

Adds a try-catch around CSV parsing in useCsvUpload. On successful parse, validates the first row's address before setting rawData; if missing/invalid, sets noCsv and returns. On parse error, logs the error and sets noCsv without updating rawData.

Changes

Cohort / File(s) Change Summary
CSV Upload Hook
apps/dashboard/src/@/hooks/useCsvUpload.ts
Wrapped CSV parsing in a try-catch; only set rawData when parse succeeds and the first item's address is present; set noCsv and early-return on missing/invalid address; on parse exceptions, log error and set noCsv without updating rawData.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant UI as Dashboard UI
  participant H as useCsvUpload Hook
  participant P as CSV Parser

  U->>UI: Select CSV file
  UI->>H: onFileUpload(file)
  H->>P: parse(file)
  alt Parse success
    P-->>H: data[]
    H->>H: validate first item's address
    alt Address present
      H->>UI: set rawData(data)
    else Missing/invalid address
      H->>UI: set noCsv(true)
      H-->>UI: return (no rawData update)
    end
  else Parse error
    P--x H: throw error
    H->>H: catch error, log
    H->>UI: set noCsv(true)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description includes the commented template and an AI-generated summary but does not populate the required template sections such as title, Notes for the reviewer, and How to test, leaving essential information missing. Please fill out the PR description by removing the placeholder comments and adding the required sections with a concise title, reviewer notes, and detailed testing instructions following the repository template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely summarizes the primary change of adding error UI support for CSV parsing failures and references the issue tag for context, making it clear and relevant to the changeset.
Linked Issues Check ✅ Passed The changes introduce a try-catch around CSV parsing and set an error state when parsing fails or the address is missing, fulfilling the linked issue’s requirement to surface clear error indication in the dashboard UI when CSV parsing errors occur.
Out of Scope Changes Check ✅ Passed All modifications are confined to the useCsvUpload hook’s error handling logic, which aligns with the issue objective and no unrelated files or features were altered.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bld-395

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 511aa04 and fe940b3.

📒 Files selected for processing (1)
  • apps/dashboard/src/@/hooks/useCsvUpload.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/src/@/hooks/useCsvUpload.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Analyze (javascript)

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

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

@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.02%. Comparing base (080d7f2) to head (fe940b3).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8223   +/-   ##
=======================================
  Coverage   55.02%   55.02%           
=======================================
  Files         919      919           
  Lines       60583    60583           
  Branches     4126     4126           
=======================================
  Hits        33333    33333           
  Misses      27146    27146           
  Partials      104      104           
Flag Coverage Δ
packages 55.02% <ø> (ø)
🚀 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: 0

🧹 Nitpick comments (1)
apps/dashboard/src/@/hooks/useCsvUpload.ts (1)

122-132: LGTM! Consider enhancing error logging for better debugging.

The try-catch wrapper correctly handles CSV parsing errors by setting noCsv to true, which should trigger the error UI as intended by the PR objective.

However, the error logging could be more descriptive for developers debugging issues. The existing file validation error (lines 114-116) provides a helpful message, while the catch block only logs the raw error object.

Apply this diff to improve error logging:

 } catch (error) {
-  console.error(error);
+  console.error("Failed to parse CSV file:", error);
   setNoCsv(true);
 }

Optionally, for production monitoring, consider integrating an error tracking service (e.g., Sentry, LogRocket) to capture and alert on parsing failures:

 } catch (error) {
-  console.error(error);
+  console.error("Failed to parse CSV file:", error);
+  // errorTracker.captureException(error, { context: "CSV parsing" });
   setNoCsv(true);
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ae75073 and 511aa04.

📒 Files selected for processing (1)
  • apps/dashboard/src/@/hooks/useCsvUpload.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • apps/dashboard/src/@/hooks/useCsvUpload.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • apps/dashboard/src/@/hooks/useCsvUpload.ts
apps/{dashboard,playground-web}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
Use NavLink for internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Use cn() from @/lib/utils for conditional class logic
Use design system tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components (Node edge): Start files with import "server-only";
Client Components (browser): Begin files with 'use client';
Always call getAuthToken() to retrieve JWT from cookies on server side
Use Authorization: Bearer header – never embed tokens in URLs
Return typed results (e.g., Project[], User[]) – avoid any
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stable queryKeys for React Query cache hits
Configure staleTime/cacheTime in React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never import posthog-js in server components

Files:

  • apps/dashboard/src/@/hooks/useCsvUpload.ts
apps/{dashboard,playground}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/{dashboard,playground}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/_ (e.g., Button, Input, Tabs, Card)
Use NavLink for internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names with cn() from @/lib/utils for conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start with import "server-only"; use next/headers, server‑only env, heavy data fetching, and redirect() where appropriate
Client Components must start with 'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: call getAuthToken() from cookies, send Authorization: Bearer <token> header, and return typed results (avoid any)
Client-side data fetching: wrap calls in React Query with descriptive, stable queryKeys and set sensible staleTime/cacheTime (≥ 60s default); keep tokens secret via internal routes or server actions
Do not import posthog-js in server components (client-side only)

Files:

  • apps/dashboard/src/@/hooks/useCsvUpload.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)

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 (2)
apps/dashboard/src/@/hooks/useCsvUpload.ts (2)

122-132: Consider distinguishing between error types for better user feedback.

The catch block captures all errors without differentiating between CSV parsing errors, validation errors, or errors thrown by csvParser. Users would benefit from specific error messages (e.g., "Invalid CSV headers" vs "CSV parsing failed").

Consider storing the error message and type:

+ const [csvError, setCsvError] = useState<string | null>(null);

  const setFiles = useCallback(
    (acceptedFiles: File[]) => {
      setNoCsv(false);
+     setCsvError(null);
      // ... rest of the code
      Papa.parse(csv, {
        complete: (results) => {
          try {
            const data = props.csvParser(results.data as T[]);
            if (!data[0]?.address) {
+             setCsvError("Missing 'address' column in CSV headers");
              setNoCsv(true);
              return;
            }
            setRawData(data);
          } catch (error) {
-           console.error(error);
+           setCsvError(error instanceof Error ? error.message : "Failed to parse CSV");
+           console.error("CSV parsing error:", error);
            setNoCsv(true);
          }
        },
        header: true,
      });
    },
-   [props.csvParser],
+   [props.csvParser, setCsvError],
  );

  return {
    noCsv,
+   csvError,
    // ... rest of the return values
  };

187-198: Consider adding error handling to processData for consistency.

The processData function performs similar validation (lines 191-194) but lacks try-catch protection. If csvParser can throw errors in setFiles, it can likely throw in processData as well.

Apply similar error handling to processData:

  const processData = useCallback(
    (data: T[]) => {
      setNoCsv(false);
-     const processedData = props.csvParser(data);
-     if (!processedData[0]?.address) {
-       setNoCsv(true);
-       return;
-     }
-     setRawData(processedData);
+     try {
+       const processedData = props.csvParser(data);
+       if (!processedData[0]?.address) {
+         setNoCsv(true);
+         return;
+       }
+       setRawData(processedData);
+     } catch (error) {
+       console.error("Data processing error:", error);
+       setNoCsv(true);
+     }
    },
    [props.csvParser],
  );
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ae75073 and 511aa04.

📒 Files selected for processing (1)
  • apps/dashboard/src/@/hooks/useCsvUpload.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • apps/dashboard/src/@/hooks/useCsvUpload.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • apps/dashboard/src/@/hooks/useCsvUpload.ts
apps/{dashboard,playground-web}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
Use NavLink for internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Use cn() from @/lib/utils for conditional class logic
Use design system tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components (Node edge): Start files with import "server-only";
Client Components (browser): Begin files with 'use client';
Always call getAuthToken() to retrieve JWT from cookies on server side
Use Authorization: Bearer header – never embed tokens in URLs
Return typed results (e.g., Project[], User[]) – avoid any
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stable queryKeys for React Query cache hits
Configure staleTime/cacheTime in React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never import posthog-js in server components

Files:

  • apps/dashboard/src/@/hooks/useCsvUpload.ts
apps/{dashboard,playground}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/{dashboard,playground}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/_ (e.g., Button, Input, Tabs, Card)
Use NavLink for internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names with cn() from @/lib/utils for conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start with import "server-only"; use next/headers, server‑only env, heavy data fetching, and redirect() where appropriate
Client Components must start with 'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: call getAuthToken() from cookies, send Authorization: Bearer <token> header, and return typed results (avoid any)
Client-side data fetching: wrap calls in React Query with descriptive, stable queryKeys and set sensible staleTime/cacheTime (≥ 60s default); keep tokens secret via internal routes or server actions
Do not import posthog-js in server components (client-side only)

Files:

  • apps/dashboard/src/@/hooks/useCsvUpload.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/dashboard/src/@/hooks/useCsvUpload.ts (2)

124-127: Edge case: Empty data array after parsing.

If csvParser returns an empty array, data[0]?.address evaluates to undefined, triggering the error state. Confirm this is the intended behavior, as an empty CSV might warrant a different message than one with missing headers.


122-132: noCsv correctly drives error UI
Components using useCsvUpload pass csvUpload.noCsv to isError props and error titles in the upload components, ensuring parsing failures surface to the user.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.51 KB (0%) 1.3 s (0%) 143 ms (+69.87% 🔺) 1.5 s
thirdweb (cjs) 365.79 KB (0%) 7.4 s (0%) 703 ms (-9.09% 🔽) 8.1 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 44 ms (+1162.29% 🔺) 158 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 43 ms (+700.19% 🔺) 53 ms
thirdweb/react (minimal + tree-shaking) 19.13 KB (0%) 383 ms (0%) 42 ms (+1039.95% 🔺) 425 ms

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 9, 2025

Merge activity

<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR improves error handling in the `useCsvUpload` hook by adding a `try-catch` block around the CSV parsing logic. It ensures that if an error occurs during parsing or if the parsed data lacks an address, the component sets an error state and logs the error.

### Detailed summary
- Introduced a `try-catch` block around the CSV parsing logic.
- Added error handling to set `noCsv` to `true` if the parsed data's first entry does not have an `address`.
- Ensured that any errors during parsing are logged to the console.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Bug Fixes**
  * Prevents crashes during CSV uploads by handling parse errors gracefully.
  * Ensures invalid or malformed CSV files are detected and flagged without updating data.
  * Maintains existing behavior for valid files, only updating data when required fields are present.
  * Improves reliability of the upload flow with clearer invalid-file handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app bot deleted the bld-395 branch October 9, 2025 18:41
@vercel vercel bot temporarily deployed to Production – nebula October 9, 2025 18:41 Inactive
@vercel vercel bot temporarily deployed to Production – docs-v2 October 9, 2025 18:41 Inactive
@vercel vercel bot temporarily deployed to Production – wallet-ui October 9, 2025 18:41 Inactive
@vercel vercel bot temporarily deployed to Production – thirdweb_playground October 9, 2025 18:41 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dashboard Involves changes to the Dashboard.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants