BlueGit

timfa bluegit

fix(api): release aanmaken op privé repo geeft niet-leden 404

timfa Tim Falken · pushed by timfa

Authored 2026-10-24 · 3 weeks ago

Hash
aa84e359d57f628d3f1ce17d09ed1ddc25b4390b
Parent
e20acdac
Pipeline
Passed
2 files changed +5 −0
internal/server/api.go +4 −0
@@ -49,6 +49,10 @@ func (s *Server) createRelease(w http.ResponseWriter, r *http.Request) {
49 49 return
50 50 }
51 51 role, err := s.Store.EffectiveRole(r.Context(), author.ID, repo.ID)
52 if err == nil && !role.CanRead() && repo.Visibility != "public" {
53 s.writeAPIErr(w, r, fail(http.StatusNotFound, i18n.E("err.notFound")))
54 return
55 }
52 56 if err != nil || !role.AtLeast(access.RoleMaintainer) {
53 57 s.writeAPIErr(w, r, fail(http.StatusForbidden, i18n.E("err.onlyAdmin")))
54 58 return
@@ -49,6 +49,10 @@ func (s *Server) createRelease(w http.ResponseWriter, r *http.Request) {
49 return
49 return
50 }
50 }
51 role, err := s.Store.EffectiveRole(r.Context(), author.ID, repo.ID)
51 role, err := s.Store.EffectiveRole(r.Context(), author.ID, repo.ID)
52 if err == nil && !role.CanRead() && repo.Visibility != "public" {
53 s.writeAPIErr(w, r, fail(http.StatusNotFound, i18n.E("err.notFound")))
54 return
55 }
52 if err != nil || !role.AtLeast(access.RoleMaintainer) {
56 if err != nil || !role.AtLeast(access.RoleMaintainer) {
53 s.writeAPIErr(w, r, fail(http.StatusForbidden, i18n.E("err.onlyAdmin")))
57 s.writeAPIErr(w, r, fail(http.StatusForbidden, i18n.E("err.onlyAdmin")))
54 return
58 return
internal/server/api_visibility_test.go +1 −0
@@ -145,6 +145,7 @@ func TestAPIAnonymousReadsRespectVisibility(t *testing.T) {
145 145 p := "/api/v1/projects/" + f.path
146 146 return []string{
147 147 p + "/merge_requests",
148 p + "/releases",
148 149 fmt.Sprintf("%s/merge_requests/%d/notes", p, f.mr),
149 150 fmt.Sprintf("%s/pipelines/%d/retry", p, f.pipe),
150 151 "/api/v1/repos/" + f.path + "/issues",
@@ -145,6 +145,7 @@ func TestAPIAnonymousReadsRespectVisibility(t *testing.T) {
145 p := "/api/v1/projects/" + f.path
145 p := "/api/v1/projects/" + f.path
146 return []string{
146 return []string{
147 p + "/merge_requests",
147 p + "/merge_requests",
148 p + "/releases",
148 fmt.Sprintf("%s/merge_requests/%d/notes", p, f.mr),
149 fmt.Sprintf("%s/merge_requests/%d/notes", p, f.mr),
149 fmt.Sprintf("%s/pipelines/%d/retry", p, f.pipe),
150 fmt.Sprintf("%s/pipelines/%d/retry", p, f.pipe),
150 "/api/v1/repos/" + f.path + "/issues",
151 "/api/v1/repos/" + f.path + "/issues",