Bug Description
Multiple components in the codebase use repo_name.split('/') without checking if the repo_name contains a '/' character. This can cause runtime errors when repo_name is:
- An empty string
- A string without '/' separator
- Malformed
Affected Files
apps/web/app/ai-home-content.tsx (lines 329, 333, 347)
apps/web/app/trending/ai/content.tsx (line 62)
apps/web/app/analyze/(repo)/[owner]/[repo]/_sections/SimilarReposRadial.tsx (line 89)
Example
// Current code
const owner = repo.repo_name.split('/')[0] || '';
const shortName = repo.repo_name.split('/')[1] || repo.repo_name;
If repo_name is `` or somerepo (no slash):
split('/')[1] returns undefined
- Fallback to
repo.repo_name is not the intended behavior
- Avatar URL becomes
https://github.com/.png?size=40 (invalid)
Suggested Fix
Add proper validation before splitting:
const parts = repo.repo_name?.split('/') ?? [];
const owner = parts[0] || '';
const shortName = parts[1] || repo.repo_name;
Or use a helper function:
function parseRepoName(repoName: string): { owner: string; repo: string } {
const parts = repoName?.split('/') ?? [];
if (parts.length >= 2) {
return { owner: parts[0], repo: parts[1] };
}
return { owner: '', repo: repoName };
}
Impact
- Broken avatar images for repos with malformed names
- Incorrect display names in treemap and other visualizations
- Potential console errors in production
Bug Description
Multiple components in the codebase use
repo_name.split('/')without checking if the repo_name contains a '/' character. This can cause runtime errors when repo_name is:Affected Files
apps/web/app/ai-home-content.tsx(lines 329, 333, 347)apps/web/app/trending/ai/content.tsx(line 62)apps/web/app/analyze/(repo)/[owner]/[repo]/_sections/SimilarReposRadial.tsx(line 89)Example
If
repo_nameis `` orsomerepo(no slash):split('/')[1]returnsundefinedrepo.repo_nameis not the intended behaviorhttps://github.com/.png?size=40(invalid)Suggested Fix
Add proper validation before splitting:
Or use a helper function:
Impact