A deployable markdown editor that connects with your self hosted files and lets you edit in a beautiful interface
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve repository listing with better error logging and scope

- Add 'affiliation' parameter to GitHub API call to include all repos
- Include owner, collaborator, and organization_member repositories
- Add detailed error logging with status codes
- Log token prefix for debugging
- Log successful repository count
- This ensures users see all repos they have access to, not just owned

+12 -6
+8 -3
backend/internal/api/handlers/repos.go
··· 2 2 3 3 import ( 4 4 "encoding/json" 5 + "fmt" 5 6 "log" 6 7 "net/http" 7 8 "strings" ··· 40 41 // Get user's GitHub access token 41 42 token, err := h.db.GetAuthToken(userID, "github") 42 43 if err != nil { 43 - log.Printf("Failed to get auth token: %v", err) 44 + log.Printf("Failed to get auth token for user %d: %v", userID, err) 44 45 http.Error(w, "Failed to get auth token", http.StatusInternalServerError) 45 46 return 46 47 } 48 + 49 + log.Printf("Listing repositories for user %d with token: %s...", userID, token.AccessToken[:min(10, len(token.AccessToken))]) 47 50 48 51 // Create GitHub connector 49 52 connector := connectors.NewGitHubConnector(token.AccessToken) ··· 57 60 // List repositories 58 61 repos, err := connector.ListRepositories(r.Context(), sortBy) 59 62 if err != nil { 60 - log.Printf("Failed to list repositories: %v", err) 61 - http.Error(w, "Failed to list repositories", http.StatusInternalServerError) 63 + log.Printf("Failed to list repositories for user %d: %v", userID, err) 64 + http.Error(w, fmt.Sprintf("Failed to list repositories: %v", err), http.StatusInternalServerError) 62 65 return 63 66 } 67 + 68 + log.Printf("Successfully listed %d repositories for user %d", len(repos), userID) 64 69 65 70 response := map[string]interface{}{ 66 71 "repositories": repos,
+4 -3
backend/internal/connectors/github.go
··· 48 48 } 49 49 50 50 opts := &github.RepositoryListOptions{ 51 - Sort: sort, 52 - Direction: "desc", 51 + Sort: sort, 52 + Direction: "desc", 53 + Affiliation: "owner,collaborator,organization_member", // Include all repos user has access to 53 54 ListOptions: github.ListOptions{ 54 55 PerPage: 100, 55 56 }, ··· 60 61 for { 61 62 repos, resp, err := g.client.Repositories.List(ctx, "", opts) 62 63 if err != nil { 63 - return nil, fmt.Errorf("failed to list repositories: %w", err) 64 + return nil, fmt.Errorf("failed to list repositories (status: %v): %w", resp.StatusCode, err) 64 65 } 65 66 66 67 for _, repo := range repos {