Skip to content

refactor: replace catch (error: any) with unknown and add type narrowing - #4212

Merged
1 commit merged into
RatLoopz:mainfrom
kumudasrip:fix/TypeScript-Refactoring
Aug 8, 2026
Merged

refactor: replace catch (error: any) with unknown and add type narrowing#4212
1 commit merged into
RatLoopz:mainfrom
kumudasrip:fix/TypeScript-Refactoring

Conversation

@kumudasrip

Copy link
Copy Markdown
Contributor

🛑 STOP: Assignment & File Scope Check

  • I am assigned to this issue.
  • I verified that this PR ONLY touches the required files.

Warning

PRs with unrelated files will not be reviewed and may be closed.

📋 PR Summary & Link

  • **Closes [BUG] TypeScript Refactoring: Widespread use of catch (error: any) #4188 **
  • Summary: Codebase-wide refactoring to replace all occurrences of catch (error: any) (including variants like err: any and dbError: any) with catch (error: unknown). Proper error type narrowing was added across all modified files using instanceof Error and runtime object checks to safely access properties like error.message and error.status in strict mode.

📸 Proof of Work (Screenshots / Logs)

Important

No Pull Request will be merged without proof of testing!

  • Frontend/UI changes: You MUST attach screenshots or screen recordings (GIFs/Videos) showing the UI changes.

Please drag & drop your screenshots/GIFs here:
This is a pure TypeScript refactoring without UI changes

🏷️ PR Type

  • 🐛 type: bug
  • type: feature
  • 📖 type: docs
  • 🧪 type: testing
  • 🔒 type: security
  • type: performance
  • 🎨 type: design
  • ♻️ type: refactor
  • 🛠️ type: devops
  • type: accessibility

✅ Checklist

  • My PR has a linked issue (Closes #4188)
  • I have pulled the latest main and resolved any conflicts

@github-project-automation github-project-automation Bot moved this to 📥 Backlog in SahiDawa Workflow Aug 7, 2026
@github-actions github-actions Bot added gssoc:approved Approved for gssoc type:bug Something isn't working labels Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Warning: Large Pull Request Detected
This PR modifies 18 files.
Please review the "Files changed" tab. Did you accidentally run git add . or commit files from other branches?
(If this is a legitimate large feature like a major refactor or i18n update, you can ignore this warning).

@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
10.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@kumudasrip

Copy link
Copy Markdown
Contributor Author

Hello @dipexplorer

Just wanted to provide some context on the failing checks, specifically the SonarCloud Quality Gate warning regarding code duplication.

Since this PR resolves the widespread codebase refactoring of catch (error: any) to catch (error: unknown) (Issue #4188 ), it required adding safe type-narrowing logic across multiple API routes and frontend components (e.g., error instanceof Error ? error.message : String(error)). SonarCloud is flagging this repeated error-handling pattern as "Duplication on New Code," but this is actually the necessary boilerplate for safe and strict TypeScript error handling.

Regarding the other CI and E2E test failures, they might be related to flaky tests on the main branch, as the core of this PR purely replaces any with unknown and safely handles the error objects without changing the underlying business logic.

Could you please review and merge the PR whenever possible? Thank you!

@dipexplorer dipexplorer closed this pull request by merging all changes into RatLoopz:main in 623f66e Aug 8, 2026
@github-project-automation github-project-automation Bot moved this from 📥 Backlog to 🎉 Merged in SahiDawa Workflow Aug 8, 2026
@dipexplorer dipexplorer added level:intermediate 35 pts type:refactor Code structure cleanup without behavior change type:performance Performance optimization or latency improvements labels Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for gssoc level:intermediate 35 pts type:bug Something isn't working type:performance Performance optimization or latency improvements type:refactor Code structure cleanup without behavior change

Projects

Status: 🎉 Merged

Development

Successfully merging this pull request may close these issues.

[BUG] TypeScript Refactoring: Widespread use of catch (error: any)

2 participants