iiitl / iiitl/Opensource_Compass

Fix: Setup Guide Shows `undefined/repo` and GitHub Links Are Broken

Open
#56 0 comments 0 reactions 0 assignees View on GitHub
backend bug frontend intermediate
Dominant language
TypeScript
Stars
0
Forks
16
PR merge metrics
No merged PRs in 30d

Description

### πŸ“‹ Description

The Setup Guide page is broken for a subset of repositories. When a user clicks "Setup Guide", the page shows:

```
Setup Guide: undefined/puppeteer
Error: Failed to generate setup guide: Internal Server Error
```

The github-service logs show the exact malformed request:
```
GET "/repos/undefined/puppeteer/readme" β†’ 500
```

There are **two root causes**, both of which must be fixed for this issue to be fully resolved.

---

### πŸ” Root Cause #1 β€” Backend: `repo_id` is missing the owner

In `backend/core_service/internal/orchestration/repo_search.go` (line 49–53):

```go
var results []string
for _, r := range repos {
repoID := r.FullName
if repoID == "" {
repoID = r.Name // ← BUG: r.Name is just "puppeteer" with no owner
}
results = append(results, repoID)
}
```

When `r.FullName` is empty for any reason, the fallback `r.Name` produces a bare repo name without an owner (e.g., `"puppeteer"` instead of `"puppeteer/puppeteer"`). This propagates through the entire recommendation pipeline.

### πŸ” Root Cause #2 β€” Frontend: Swapped owner/repo labels + no guard on `split`

In `frontend/app/(auth)/recommendations/components/recommendationhero.tsx` (line 15 and 42–43):

```tsx
const [owner, repo] = repoId.split('/');
// If repoId = "puppeteer" (no slash):
// owner = "puppeteer"
// repo = undefined ← JavaScript undefined!

// Then in the JSX:

{repo}/ {owner}


// undefined "puppeteer"
// Renders: "undefined / puppeteer"
```

When `repo` is JavaScript `undefined` and gets used in template literals (e.g., for navigation), it becomes the **string** `"undefined"` β€” which is what the URL and API call contain.

---

### πŸ“ Files to Change

**Backend:**
- `backend/core_service/internal/orchestration/repo_search.go`

**Frontend:**
- `frontend/app/(auth)/recommendations/components/recommendationhero.tsx`
- `frontend/app/(auth)/recommendations/components/featuredissues.tsx` *(secondary broken link)*

---

### βœ… What To Fix

**Fix 1 β€” `repo_search.go`: Remove the unsafe fallback**

```go
for _, r := range repos {
repoID := r.FullName
if repoID == "" {
// Don't fall back to r.Name β€” it lacks the owner and will
// cause "undefined/repo" errors downstream. Skip this entry instead.
log.Printf("SearchReposForUser: skipping repo with empty FullName: %s", r.Name)
continue
}
results = append(results, repoID)
}
```

**Fix 2 β€” `recommendationhero.tsx`: Guard the split and fix the swapped display**

```tsx
// Line 15 β€” safe split with fallback:
const parts = repoId.split('/');
const owner = parts.length === 2 ? parts[0] : '';
const repo = parts.length === 2 ? parts[1] : parts[0];

// Line 42–43 β€” the display was also swapped (showing repo/owner backwards):
// Current (wrong): {repo}/ {owner}
// Fixed (correct): {owner}/ {repo}
```

**Fix 3 β€” `featuredissues.tsx`: The "View on GitHub" button links to the issues list**

```tsx
// Line 87 β€” currently:
onClick={() => window.open(`https://github.com/${repoId}/issues`, '_blank')}

// If repoId = "puppeteer" (missing owner), this gives:
// https://github.com/puppeteer/issues β†’ 404

// Fix: guard against missing owner/repo format:
const githubIssuesUrl = repoId.includes('/')
? `https://github.com/${repoId}/issues`
: `https://github.com/search?q=${repoId}`;

onClick={() => window.open(githubIssuesUrl, '_blank')}
```

---

### 🏁 Acceptance Criteria

- [ ] `repo_search.go` no longer falls back to `r.Name` β€” repos with empty `FullName` are skipped with a log warning
- [ ] The recommendations page shows `owner/repo` in correct order (not `repo / owner`)
- [ ] Setting up a repo whose `repo_id` has no `/` no longer shows `undefined` anywhere in the UI
- [ ] "View on GitHub" in Featured Issues links to a working URL
- [ ] Frontend builds with no TypeScript errors: `cd frontend && npm run build`
- [ ] Backend compiles: `cd backend/core_service && go build ./...`

---

### πŸ’‘ Technical Hints

- The `GitHubRepo` struct (`clients/github_models.go`) has both `FullName string` and `Name string`. `FullName` is always like `"owner/repo"`. If it's empty, something went wrong parsing the GitHub API response β€” the right fix is to skip/log, not to use the bare `Name`
- In the frontend, `"puppeteer".split("/")` returns `["puppeteer"]` β€” `[1]` is `undefined` (not the string `"undefined"`, but actual `undefined`). When embedded in a template literal like `` `${owner}/${repo}` ``, JavaScript coerces it to the string `"undefined"` which then gets sent in the URL
- After the backend fix, verify by checking that all `repo_id` values in the recommendations API response contain a `/`

---

### πŸš€ Getting Started

1. Fork the repository
2. Create a branch: `git checkout -b fix/issue-34-undefined-repo-setup-guide`
3. Fix `backend/core_service/internal/orchestration/repo_search.go`
4. Fix `frontend/app/(auth)/recommendations/components/recommendationhero.tsx`
5. Fix `frontend/app/(auth)/recommendations/components/featuredissues.tsx`
6. Start the app: `docker-compose up --build` + `npm run dev`
7. Navigate to Recommendations, click a repo's Setup Guide β€” it should work
8. Open a PR with before/after screenshots!

Contributor guide

Open the contributing guide

Research direction

Start with backend/core_service/internal/orchestration/repo_search.go and the two recommendation components, then run the frontend build and backend build commands listed in the issue. Done means repository identifiers remain owner/repo, the recommendations UI displays them in that order without undefined values, Featured Issues opens a working URL, and both builds pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, typescript
Domain
backend, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.