Skip to content

api: fix nil pointer dereference when listing user repos#8069

Merged
unknwon merged 2 commits intogogs:mainfrom
mukaiu:main
Jan 19, 2026
Merged

api: fix nil pointer dereference when listing user repos#8069
unknwon merged 2 commits intogogs:mainfrom
mukaiu:main

Conversation

@mukaiu
Copy link
Contributor

@mukaiu mukaiu commented Dec 12, 2025

Describe the pull request

In listUserRepositories, after querying the associated repo, attributes were not loaded, causing BaseRepo to be nil when executing apiRepo.Parent = r.BaseRepo.APIFormatLegacy(p) in APIFormatLegacy. Add code to load attributes to fix this issue.

Link to the issue: Closes #7830

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code or have provided the test plan.

Test plan

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a nil pointer dereference error in the /api/v1/user/repos endpoint. When a user has collaborator access to forked repositories, the attributes (specifically BaseRepo for forks) were not loaded before calling APIFormatLegacy, causing a crash.

Key changes:

  • Added attribute loading for accessible repositories (repositories where the user is a collaborator) before formatting them for API response

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unknwon unknwon changed the title Fix the nil pointer dereference error occurring when calling the API /api/v1/user/repos. Fix the nil pointer dereference in repo listing API Jan 10, 2026
@unknwon unknwon changed the title Fix the nil pointer dereference in repo listing API Fix the nil pointer dereference in listing user repos API Jan 10, 2026
@unknwon unknwon changed the title Fix the nil pointer dereference in listing user repos API Fix nil pointer dereference in listing user repos API Jan 10, 2026
@unknwon unknwon changed the title Fix nil pointer dereference in listing user repos API api: fix nil pointer dereference when listing user repos Jan 10, 2026
@unknwon unknwon added this to the 0.13.4 milestone Jan 10, 2026
Copy link
Member

@unknwon unknwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@unknwon unknwon merged commit 3ef71a4 into gogs:main Jan 19, 2026
11 of 12 checks passed
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (3650b32) to head (91d1a4e).
⚠️ Report is 163 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #8069       +/-   ##
==========================================
- Coverage   15.28%       0   -15.29%     
==========================================
  Files         106       0      -106     
  Lines       13864       0    -13864     
==========================================
- Hits         2119       0     -2119     
+ Misses      11465       0    -11465     
+ Partials      280       0      -280     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

unknwon added a commit that referenced this pull request Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API /api/v1/user/repos returns 500

3 participants