Skip to content

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

@Vedant1703

Description

@Vedant1703

📋 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):

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):

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

// Then in the JSX:
<h1>{repo}<span>/ {owner}</span></h1>
//   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

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

// 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}<span>/ {owner}</span>
// Fixed (correct):  {owner}<span>/ {repo}</span>

Fix 3 — featuredissues.tsx: The "View on GitHub" button links to the issues list

// 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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions