Skip to content

fix: improve type safety in Signup.tsx error handling#359

Open
Jai-Shankar1033 wants to merge 1 commit into
GitMetricsLab:mainfrom
Jai-Shankar1033:fix/signup-type-safety
Open

fix: improve type safety in Signup.tsx error handling#359
Jai-Shankar1033 wants to merge 1 commit into
GitMetricsLab:mainfrom
Jai-Shankar1033:fix/signup-type-safety

Conversation

@Jai-Shankar1033
Copy link
Copy Markdown

@Jai-Shankar1033 Jai-Shankar1033 commented May 21, 2026

Related Issue

-#347


Description

  • Replaced catch (error: any) with catch (error: unknown) in Signup.tsx to improve TypeScript type safety.
    -Added the axios.isAxiosError() type guard to safely access error response data, with a fallback message for non-Axios errors.

How Has This Been Tested?

  • Manually tested the signup form with valid and invalid inputs
  • Verified error messages display correctly when the server returns an error
  • Verified successful signup still navigates to /login

Screenshots (if applicable)

N/A — no UI changes, only internal error handling logic updated


Type of Change

  • Code quality improvement

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling in the signup form to provide more consistent and user-friendly error messages when signup issues occur.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 21, 2026

Deploy Preview for github-spy failed.

Name Link
🔨 Latest commit 0a78a6e
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a0ea88fe83a870009704e73

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9e6066d2-c4ac-4aa4-8896-ab7e3145af07

📥 Commits

Reviewing files that changed from the base of the PR and between 9d34c19 and 0a78a6e.

📒 Files selected for processing (1)
  • src/pages/Signup/Signup.tsx

📝 Walkthrough

Walkthrough

The signup form's handleSubmit error handling is refactored to improve type safety. The axios POST call is reformatted, and error handling now treats caught errors as unknown, uses axios.isAxiosError for type narrowing, and safely extracts response error messages with a generic fallback.

Changes

Signup form error handling improvements

Layer / File(s) Summary
Signup error handling refinement
src/pages/Signup/Signup.tsx
The handleSubmit function's axios POST request reformats the call and refines the catch block from any to unknown error type, adding axios.isAxiosError branching to safely extract response.data.message with a fallback to a generic error message when unavailable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • GitMetricsLab/github_tracker#229: Both PRs modify src/pages/Signup/Signup.tsx's handleSubmit signup axios.post and navigation logic, with this PR further refining the request formatting and error handling.
  • GitMetricsLab/github_tracker#269: This PR's error handling improvements to handleSubmit (using unknown, axios.isAxiosError, and fallback message) directly align with the retrieved PR's submit-flow and backend error message handling updates.
  • GitMetricsLab/github_tracker#265: Both PRs modify src/pages/Signup/Signup.tsx's handleSubmit submission and error-handling logic, including the axios POST call and fallback error message behavior.

Suggested labels

quality:clean, level:intermediate

Poem

A rabbit hops through types so tight,
From any darkness into light,
axios.isAxiosError guides the way,
Safe error messages come to play,
Signup flows now handled right! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: improving type safety in Signup.tsx error handling by replacing catch (error: any) with catch (error: unknown) and adding axios type guards.
Description check ✅ Passed The description includes all required template sections with relevant details: Related Issue, Description of changes, testing approach, and Type of Change. Minor formatting inconsistency with 'Closes:' prefix missing, but substance is complete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant