fix : resolve TypeScript errors in upstream main#2464
Conversation
- 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
|
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. |
|
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR makes three focused fixes: Bitbucket and GitLab service interceptors now coerce ChangesRate-limit header string coercion
Frontend component TypeScript and useMemo fixes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/components/repository/RepositoryInsights.tsx (1)
19-20: 🧹 Nitpick | 🔵 TrivialUse
CodeMetricsPropsdirectly instead of dropping toanyand remove JSX@ts-ignoreworkarounds.Line 19 narrows the prop contract to
any, and lines 263/267 use@ts-ignorecomments to suppress type errors. SinceCodeMetricsPropsis 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
📒 Files selected for processing (5)
lib/services/bitbucketService.tslib/services/gitlabService.tssrc/components/repository/CodeMetrics.tsxsrc/components/repository/RepositoryInsights.tsxsrc/components/visualizations/CodeDependencyGraph.tsx
| let retrySeconds = 60 | ||
| if (retryAfterHeader) { | ||
| retrySeconds = parseInt(retryAfterHeader, 10) | ||
| retrySeconds = parseInt(String(retryAfterHeader), 10) |
There was a problem hiding this comment.
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.
| 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.
| retrySeconds = parseInt(String(retryAfterHeader), 10) | ||
| } else if (resetHeader) { | ||
| const resetTime = parseInt(resetHeader, 10) * 1000 | ||
| const resetTime = parseInt(String(resetHeader), 10) * 1000 |
There was a problem hiding this comment.
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.
| 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.
| 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]); |
There was a problem hiding this comment.
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)
|
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. |
Summary
This PR fixes pre-existing TypeScript errors that were introduced in upstream main and are blocking all open PRs.
Changes
retry-afterheader tostringbeforeparseInt(fixesTS2345)retry-afterandratelimit-resetheadersnodeChurnMapuseMemo aftergraphDatadeclaration to fix forward-reference error (TS2448)ContributorIssueRecommendationsfrom./to@/components/(TS2307)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
Refactor