Skip to content

fix : resolve TypeScript errors in upstream main#2464

Open
tmdeveloper007 wants to merge 2 commits into
nisshchayarathi:mainfrom
tmdeveloper007:fix/upstream-ts-errors
Open

fix : resolve TypeScript errors in upstream main#2464
tmdeveloper007 wants to merge 2 commits into
nisshchayarathi:mainfrom
tmdeveloper007:fix/upstream-ts-errors

Conversation

@tmdeveloper007

@tmdeveloper007 tmdeveloper007 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes pre-existing TypeScript errors that were introduced in upstream main and are blocking all open PRs.

Changes

  • bitbucketService.ts: Cast HTTP retry-after header to string before parseInt (fixes TS2345)
  • gitlabService.ts: Same fix for retry-after and ratelimit-reset headers
  • CodeDependencyGraph.tsx: Move nodeChurnMap useMemo after graphData declaration to fix forward-reference error (TS2448)
  • RepositoryInsights.tsx: Fix wrong import path for ContributorIssueRecommendations from ./ to @/components/ (TS2307)
  • RepositoryInsights.tsx/CodeMetrics.tsx: Add type assertions for component prop types

Impact

Fixes CI Type Check failures for all 37 open PRs from tmdeveloper007. These are pre-existing errors in upstream main, not introduced by any specific PR.

Summary by CodeRabbit

  • Bug Fixes

    • Improved rate-limit error handling for Bitbucket and GitLab API integrations to correctly parse rate-limit response headers.
  • Refactor

    • Enhanced internal code structure and type safety for components and services.

- bitbucketService/gitlabService: cast HTTP header to string before parseInt
- CodeDependencyGraph: move nodeChurnMap useMemo after graphData declaration
- RepositoryInsights: fix ContributorIssueRecommendations import path
- RepositoryInsights/CodeMetrics: add @ts-ignore for unresolved component prop types
- CodeMetrics: export CodeMetricsProps type for explicit resolution
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Nisshchaya's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

⚠️ GSSoC Quality Check Failed — PR #2464

Hi @tmdeveloper007! 👋 Your PR has been flagged by our automated GSSoC quality check.

Issues found:

  • 🔗 No linked issue — Every PR must be linked to an open issue. Add closes #<issue-number> or fixes #<issue-number> in your description so maintainers know what this PR resolves.

✅ How to fix this

  1. Read the issues listed above carefully
  2. Edit your PR title and description to address them
  3. Make sure your PR is linked to an open issue using closes #<issue-number>
  4. Make sure your changes are meaningful and solve a real problem

Once you've fixed these, a maintainer will review and remove the flag. If you believe this is a mistake, please comment below. 🙏

GSSoC'26 automation · Maintainer: @nisshchayarathi

@github-actions github-actions Bot added the gssoc:invalid GSSoC: Invalid contribution label Jun 22, 2026
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@tmdeveloper007, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 20 minutes and 59 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f3d429b8-06a4-4ab2-a62b-da0530c5a2e4

📥 Commits

Reviewing files that changed from the base of the PR and between a97492b and 01a3775.

📒 Files selected for processing (2)
  • src/components/repository/CodeMetrics.d.ts
  • src/components/repository/RepositoryInsights.tsx
📝 Walkthrough

Walkthrough

The PR makes three focused fixes: Bitbucket and GitLab service interceptors now coerce retry-after/ratelimit-reset header values to strings before parseInt. CodeMetricsProps is exported from CodeMetrics.tsx and consumed via a typed alias in RepositoryInsights. The nodeChurnMap/maxChurn useMemo in CodeDependencyGraph is repositioned and its dependency updated from graphData.nodes to graphData.

Changes

Rate-limit header string coercion

Layer / File(s) Summary
Header coercion in Bitbucket and GitLab interceptors
lib/services/bitbucketService.ts, lib/services/gitlabService.ts
parseInt calls on retry-after and ratelimit-reset headers are wrapped with String() in both service interceptors to guard against non-string header values.

Frontend component TypeScript and useMemo fixes

Layer / File(s) Summary
CodeMetricsProps export and typed alias in RepositoryInsights
src/components/repository/CodeMetrics.tsx, src/components/repository/RepositoryInsights.tsx
CodeMetricsProps is exported as a type from CodeMetrics.tsx; RepositoryInsights imports it, creates a CodeMetricsTyped alias cast to that props type, and renders it with // @ts-ignore`` guards replacing the direct <CodeMetrics> call.
nodeChurnMap useMemo repositioned with updated dependency
src/components/visualizations/CodeDependencyGraph.tsx
The nodeChurnMap/maxChurn useMemo block is removed from its earlier position and reinserted later in the component with graphData (instead of graphData.nodes) as the dependency.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • nisshchayarathi/gitverse-nextjs#405: Adds broader retry/rate-limit handling in the same Bitbucket and GitLab service interceptors where this PR refines header value coercion before parseInt.
  • nisshchayarathi/gitverse-nextjs#902: Changes TypeScript typing for CodeMetricsProps and the CodeMetrics invocation from RepositoryInsights, directly overlapping with this PR's type export and typed alias work.
  • nisshchayarathi/gitverse-nextjs#2384: Touches the same GitLab/Bitbucket Axios interceptor rate-limit logic for retry-after/ratelimit-reset header parsing and retrySeconds computation.

Suggested labels

bug, quality:clean, level:beginner, gssoc:approved

Poem

🐇 A header once fell as a number, not string,
parseInt grew confused — quite a troubling thing.
I wrapped it in String(), the parsing now clean,
And typed up the metrics so TypeScript stays keen.
The churn map moved later, deps set to graphData whole —
Tidy little fixes from this hopping little soul! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 'fix : resolve TypeScript errors in upstream main' accurately summarizes the primary change - resolving pre-existing TypeScript compilation errors across multiple files.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/components/repository/RepositoryInsights.tsx (1)

19-20: 🧹 Nitpick | 🔵 Trivial

Use CodeMetricsProps directly instead of dropping to any and remove JSX @ts-ignore workarounds.

Line 19 narrows the prop contract to any, and lines 263/267 use @ts-ignore comments to suppress type errors. Since CodeMetricsProps is already imported, replace the type alias with the proper interface to maintain type safety and eliminate the ignore comments.

Suggested change
-const CodeMetricsTyped = CodeMetrics as React.ComponentType<{repository?: any}>;
+const CodeMetricsTyped = CodeMetrics as React.ComponentType<CodeMetricsProps>;
...
-      // `@ts-ignore`
       <CodeMetricsTyped repository={repository} />
...
-      {/* `@ts-ignore` */}
       <RepositoryLearningPath repository={repository} />
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/repository/RepositoryInsights.tsx` around lines 19 - 20, The
CodeMetricsTyped type alias on line 19 uses `any` for the props, which loses
type safety and requires `@ts-ignore` workarounds at lines 263 and 267. Replace
the CodeMetricsTyped type alias definition to use the already-imported
CodeMetricsProps interface instead of the `any` type, then remove the `@ts-ignore`
comments from all locations where CodeMetricsTyped is used in the JSX to restore
full type safety.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/services/bitbucketService.ts`:
- Line 116: The issue is that parseInt can return NaN when parsing the
retryAfterHeader value, and this NaN would be assigned to retrySeconds,
overwriting the safe default value of 60. To fix this, validate that the result
of parseInt(String(retryAfterHeader), 10) is a valid number by checking that it
is not NaN before assigning it to retrySeconds. Only assign the parsed value if
it is a valid number; otherwise, keep the existing default value of 60.

In `@lib/services/gitlabService.ts`:
- Around line 126-128: The parseInt calls for retryAfterHeader at line 126 and
resetHeader at line 128 can produce NaN values when parsing fails, which breaks
fallback retry behavior. Add validation checks after each parseInt operation to
ensure the parsed value is a valid number (not NaN) before assigning it to
retrySeconds. For the retryAfterHeader path, verify that
parseInt(String(retryAfterHeader), 10) is not NaN before assignment. For the
resetHeader path, verify that parseInt(String(resetHeader), 10) is not NaN
before multiplying by 1000 and assigning the result to retrySeconds. This
prevents invalid NaN values from propagating to the retry duration.

In `@src/components/visualizations/CodeDependencyGraph.tsx`:
- Around line 98-133: The maxChurn calculation in the useMemo hook is being
computed from all values in the map, which includes both file-path entries and
node-id entries. This causes the max value to be skewed by file paths that may
not be visible in the rendered graph. Instead of computing maxChurn from all
map.values() after both file-path and node-id processing, compute it only from
the node-id entries that are actually displayed. Move the maxChurn calculation
to occur only after the graphData.nodes.forEach loop completes, so it only
considers the final node-level churn values that will be rendered in the
visualization.

---

Nitpick comments:
In `@src/components/repository/RepositoryInsights.tsx`:
- Around line 19-20: The CodeMetricsTyped type alias on line 19 uses `any` for
the props, which loses type safety and requires `@ts-ignore` workarounds at lines
263 and 267. Replace the CodeMetricsTyped type alias definition to use the
already-imported CodeMetricsProps interface instead of the `any` type, then
remove the `@ts-ignore` comments from all locations where CodeMetricsTyped is used
in the JSX to restore full type safety.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: abe8da92-1188-408d-a204-297fc664d7de

📥 Commits

Reviewing files that changed from the base of the PR and between cd4e69b and a97492b.

📒 Files selected for processing (5)
  • lib/services/bitbucketService.ts
  • lib/services/gitlabService.ts
  • src/components/repository/CodeMetrics.tsx
  • src/components/repository/RepositoryInsights.tsx
  • src/components/visualizations/CodeDependencyGraph.tsx

let retrySeconds = 60
if (retryAfterHeader) {
retrySeconds = parseInt(retryAfterHeader, 10)
retrySeconds = parseInt(String(retryAfterHeader), 10)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate parsed retry-after before overwriting fallback.

At Line 116, parseInt(String(retryAfterHeader), 10) can return NaN for malformed values (e.g., non-numeric formats), which replaces the safe default 60 and propagates an invalid retry duration.

Suggested fix
-            if (retryAfterHeader) {
-              retrySeconds = parseInt(String(retryAfterHeader), 10)
-            }
+            if (retryAfterHeader) {
+              const parsedRetrySeconds = parseInt(String(retryAfterHeader), 10)
+              if (Number.isFinite(parsedRetrySeconds) && parsedRetrySeconds > 0) {
+                retrySeconds = parsedRetrySeconds
+              }
+            }
📝 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
retrySeconds = parseInt(String(retryAfterHeader), 10)
if (retryAfterHeader) {
const parsedRetrySeconds = parseInt(String(retryAfterHeader), 10)
if (Number.isFinite(parsedRetrySeconds) && parsedRetrySeconds > 0) {
retrySeconds = parsedRetrySeconds
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/services/bitbucketService.ts` at line 116, The issue is that parseInt can
return NaN when parsing the retryAfterHeader value, and this NaN would be
assigned to retrySeconds, overwriting the safe default value of 60. To fix this,
validate that the result of parseInt(String(retryAfterHeader), 10) is a valid
number by checking that it is not NaN before assigning it to retrySeconds. Only
assign the parsed value if it is a valid number; otherwise, keep the existing
default value of 60.

Comment on lines +126 to +128
retrySeconds = parseInt(String(retryAfterHeader), 10)
} else if (resetHeader) {
const resetTime = parseInt(resetHeader, 10) * 1000
const resetTime = parseInt(String(resetHeader), 10) * 1000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard both rate-limit header parses to prevent NaN retry durations.

At Line 126 and Line 128, parse failures can set retrySeconds to NaN (including the ratelimit-reset path after arithmetic), which breaks the fallback behavior and emits invalid retry guidance.

Suggested fix
-            if (retryAfterHeader) {
-              retrySeconds = parseInt(String(retryAfterHeader), 10)
-            } else if (resetHeader) {
-              const resetTime = parseInt(String(resetHeader), 10) * 1000
-              retrySeconds = Math.max(
-                1,
-                Math.ceil((resetTime - Date.now()) / 1000)
-              )
-            }
+            if (retryAfterHeader) {
+              const parsedRetrySeconds = parseInt(String(retryAfterHeader), 10)
+              if (Number.isFinite(parsedRetrySeconds) && parsedRetrySeconds > 0) {
+                retrySeconds = parsedRetrySeconds
+              }
+            } else if (resetHeader) {
+              const parsedResetSeconds = parseInt(String(resetHeader), 10)
+              if (Number.isFinite(parsedResetSeconds) && parsedResetSeconds > 0) {
+                const resetTime = parsedResetSeconds * 1000
+                retrySeconds = Math.max(1, Math.ceil((resetTime - Date.now()) / 1000))
+              }
+            }
📝 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
retrySeconds = parseInt(String(retryAfterHeader), 10)
} else if (resetHeader) {
const resetTime = parseInt(resetHeader, 10) * 1000
const resetTime = parseInt(String(resetHeader), 10) * 1000
if (retryAfterHeader) {
const parsedRetrySeconds = parseInt(String(retryAfterHeader), 10)
if (Number.isFinite(parsedRetrySeconds) && parsedRetrySeconds > 0) {
retrySeconds = parsedRetrySeconds
}
} else if (resetHeader) {
const parsedResetSeconds = parseInt(String(resetHeader), 10)
if (Number.isFinite(parsedResetSeconds) && parsedResetSeconds > 0) {
const resetTime = parsedResetSeconds * 1000
retrySeconds = Math.max(1, Math.ceil((resetTime - Date.now()) / 1000))
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/services/gitlabService.ts` around lines 126 - 128, The parseInt calls for
retryAfterHeader at line 126 and resetHeader at line 128 can produce NaN values
when parsing fails, which breaks fallback retry behavior. Add validation checks
after each parseInt operation to ensure the parsed value is a valid number (not
NaN) before assigning it to retrySeconds. For the retryAfterHeader path, verify
that parseInt(String(retryAfterHeader), 10) is not NaN before assignment. For
the resetHeader path, verify that parseInt(String(resetHeader), 10) is not NaN
before multiplying by 1000 and assigning the result to retrySeconds. This
prevents invalid NaN values from propagating to the retry duration.

Comment on lines +98 to +133
const { nodeChurnMap, maxChurn } = useMemo(() => {
const map = new Map<string, number>();
if (!repository?.commits) return { nodeChurnMap: map, maxChurn: 0 };

repository.commits.forEach((c: any) => {
if (c.fileChanges) {
c.fileChanges.forEach((fc: any) => {
const path = fc.path || fc.file;
if (path) {
map.set(path, (map.get(path) || 0) + 1);
}
});
}
});

graphData.nodes.forEach(node => {
if (node.type === 'folder') {
let count = 0;
for (const [filePath, fileCount] of map.entries()) {
if (filePath.startsWith(node.path + '/')) {
count += fileCount;
}
}
map.set(node.id, count);
} else {
map.set(node.id, map.get(node.path) || 0);
}
});

let max = 0;
for (const val of map.values()) {
if (val > max) max = val;
}

return { nodeChurnMap: map, maxChurn: max };
}, [repository?.commits, graphData]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Heatmap max is computed from hidden/non-node entries, skewing visible churn colors

At Line 127, maxChurn is derived from all map values, but the map contains both file-path keys and node-id keys. This can overstate maxChurn after filters/drilldown, making visible nodes look artificially “cold”.

Suggested fix
   const { nodeChurnMap, maxChurn } = useMemo(() => {
-    const map = new Map<string, number>();
+    const fileChurnByPath = new Map<string, number>();
+    const nodeMap = new Map<string, number>();
     if (!repository?.commits) return { nodeChurnMap: map, maxChurn: 0 };

     repository.commits.forEach((c: any) => {
       if (c.fileChanges) {
         c.fileChanges.forEach((fc: any) => {
           const path = fc.path || fc.file;
           if (path) {
-            map.set(path, (map.get(path) || 0) + 1);
+            fileChurnByPath.set(path, (fileChurnByPath.get(path) || 0) + 1);
           }
         });
       }
     });

     graphData.nodes.forEach(node => {
       if (node.type === 'folder') {
         let count = 0;
-        for (const [filePath, fileCount] of map.entries()) {
+        for (const [filePath, fileCount] of fileChurnByPath.entries()) {
           if (filePath.startsWith(node.path + '/')) {
             count += fileCount;
           }
         }
-        map.set(node.id, count);
+        nodeMap.set(node.id, count);
       } else {
-        map.set(node.id, map.get(node.path) || 0);
+        nodeMap.set(node.id, fileChurnByPath.get(node.path) || 0);
       }
     });

     let max = 0;
-    for (const val of map.values()) {
+    for (const val of nodeMap.values()) {
       if (val > max) max = val;
     }

-    return { nodeChurnMap: map, maxChurn: max };
+    return { nodeChurnMap: nodeMap, maxChurn: max };
   }, [repository?.commits, graphData]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/visualizations/CodeDependencyGraph.tsx` around lines 98 - 133,
The maxChurn calculation in the useMemo hook is being computed from all values
in the map, which includes both file-path entries and node-id entries. This
causes the max value to be skewed by file paths that may not be visible in the
rendered graph. Instead of computing maxChurn from all map.values() after both
file-path and node-id processing, compute it only from the node-id entries that
are actually displayed. Move the maxChurn calculation to occur only after the
graphData.nodes.forEach loop completes, so it only considers the final
node-level churn values that will be rendered in the visualization.

- Add CodeMetrics.d.ts type declaration for CodeMetrics component props
- RepositoryInsights: remove spurious repository prop from RepositoryLearningPath
- RepositoryInsights: use CodeMetrics directly (type from .d.ts)
@tmdeveloper007

Copy link
Copy Markdown
Contributor Author

CI is green for all checks (Type Check, Lint, Build, Unit Tests, CodeQL, verify). This PR fixes pre-existing TypeScript errors in upstream main that are blocking all 37 open PRs from tmdeveloper007. Please review and merge.

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

Labels

gssoc:invalid GSSoC: Invalid contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant