Error 500 on edit a forked repo with api #6990

Closed
opened 2025-11-02 07:12:59 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @Elbandi on GitHub (Mar 11, 2021).

  • Gitea version (or commit ref): 1.12.5+2-g1871afe63
  • Git version: 1:2.17.1-1ubuntu0.8
  • Operating system: Ubuntu bionic LTS
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes, pof code in my comment
    • No
  • Log gist:

2021/03/11 12:44:40 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference
/usr/lib/go-1.14/src/runtime/panic.go:212 (0x459619)
/usr/lib/go-1.14/src/runtime/signal_unix.go:695 (0x459468)
/gitea/routers/api/v1/repo/repo.go:539 (0x1a9987d)
/gitea/routers/api/v1/repo/repo.go:480 (0x1a9908f)
/usr/lib/go-1.14/src/reflect/value.go:460 (0x4a32ea)
/usr/lib/go-1.14/src/reflect/value.go:321 (0x4a27f3)
/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0xc356eb)
/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0xc350c9)
/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc50618)
/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x126dba4)
/gitea/modules/context/repo.go:797 (0x126db8d)
/usr/lib/go-1.14/src/reflect/value.go:460 (0x4a32ea)
/usr/lib/go-1.14/src/reflect/value.go:321 (0x4a27f3)

Description

Editing a forked repo with gitea sdk, sample code

                orgRepos, _, err := gclient.ListOrgRepos("foo", gitea.ListOrgReposOptions{})
                repoOption := orgRepos[0]
		repository, _, err = gclient.EditRepo("foo", repoOption.Name, gitea.EditRepoOption{
			Name:                      &repoOption.Name,
			Description:               &repoOption.Description,
			Website:                   &repoOption.Website,
			Private:                   &repoOption.Private,
			HasIssues:                 &repoOption.HasIssues,
			HasWiki:                   &repoOption.HasWiki,
			DefaultBranch:             &repoOption.DefaultBranch,
			HasPullRequests:           &repoOption.HasPullRequests,
			IgnoreWhitespaceConflicts: &repoOption.IgnoreWhitespaceConflicts,
			AllowMerge:                &repoOption.AllowMerge,
			AllowRebase:               &repoOption.AllowRebase,
			AllowRebaseMerge:          &repoOption.AllowRebaseMerge,
			AllowSquash:               &repoOption.AllowSquash,
			//			Archived:                  &repoOption.Archived,
		})
Originally created by @Elbandi on GitHub (Mar 11, 2021). - Gitea version (or commit ref): 1.12.5+2-g1871afe63 - Git version: 1:2.17.1-1ubuntu0.8 - Operating system: Ubuntu bionic LTS - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [X] SQLite - Can you reproduce the bug at https://try.gitea.io: - [X] Yes, pof code in my comment - [ ] No - Log gist: > 2021/03/11 12:44:40 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference /usr/lib/go-1.14/src/runtime/panic.go:212 (0x459619) /usr/lib/go-1.14/src/runtime/signal_unix.go:695 (0x459468) /gitea/routers/api/v1/repo/repo.go:539 (0x1a9987d) /gitea/routers/api/v1/repo/repo.go:480 (0x1a9908f) /usr/lib/go-1.14/src/reflect/value.go:460 (0x4a32ea) /usr/lib/go-1.14/src/reflect/value.go:321 (0x4a27f3) /gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0xc356eb) /gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0xc350c9) /gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc50618) /gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x126dba4) /gitea/modules/context/repo.go:797 (0x126db8d) /usr/lib/go-1.14/src/reflect/value.go:460 (0x4a32ea) /usr/lib/go-1.14/src/reflect/value.go:321 (0x4a27f3) ## Description Editing a forked repo with gitea sdk, sample code ``` orgRepos, _, err := gclient.ListOrgRepos("foo", gitea.ListOrgReposOptions{}) repoOption := orgRepos[0] repository, _, err = gclient.EditRepo("foo", repoOption.Name, gitea.EditRepoOption{ Name: &repoOption.Name, Description: &repoOption.Description, Website: &repoOption.Website, Private: &repoOption.Private, HasIssues: &repoOption.HasIssues, HasWiki: &repoOption.HasWiki, DefaultBranch: &repoOption.DefaultBranch, HasPullRequests: &repoOption.HasPullRequests, IgnoreWhitespaceConflicts: &repoOption.IgnoreWhitespaceConflicts, AllowMerge: &repoOption.AllowMerge, AllowRebase: &repoOption.AllowRebase, AllowRebaseMerge: &repoOption.AllowRebaseMerge, AllowSquash: &repoOption.AllowSquash, // Archived: &repoOption.Archived, }) ```
GiteaMirror added the type/bugmodifies/api labels 2025-11-02 07:12:59 -06:00
Author
Owner

@zeripath commented on GitHub (Mar 11, 2021):

Please update to 1.13.4 and report back if the problem is still present.

@zeripath commented on GitHub (Mar 11, 2021): Please update to 1.13.4 and report back if the problem is still present.
Author
Owner

@Elbandi commented on GitHub (Mar 11, 2021):

i try with https://try.gitea.io/ (1.14.0+dev-829-gbc423a1e8), and same error, here is the code :
(used this repo https://try.gitea.io/elbanditest/alchi)

package main

import (
	"code.gitea.io/sdk/gitea"
	"fmt"
	"log"
)

func checkError(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	gclient, err := gitea.NewClient("https://try.gitea.io", gitea.SetToken("xxxxx"))
	checkError(err)
	repos, _, err := gclient.ListOrgRepos("elbanditest", gitea.ListOrgReposOptions{})
	for _, data := range repos {
		if data.Name != "alchi" {
			continue
		}
		repository, _, err := gclient.EditRepo("elbanditest", data.Name, gitea.EditRepoOption{
			Name:                      &data.Name,
			Description:               &data.Description,
			Website:                   &data.Website,
			Private:                   &data.Private,
			HasIssues:                 &data.HasIssues,
			HasWiki:                   &data.HasWiki,
			DefaultBranch:             &data.DefaultBranch,
			HasPullRequests:           &data.HasPullRequests,
			IgnoreWhitespaceConflicts: &data.IgnoreWhitespaceConflicts,
			AllowMerge:                &data.AllowMerge,
			AllowRebase:               &data.AllowRebase,
			AllowRebaseMerge:          &data.AllowRebaseMerge,
			AllowSquash:               &data.AllowSquash,
			//			Archived:                  &repoOption.Archived,
		})
		fmt.Printf("%v, %v\n", repository, err)
	}
}

@Elbandi commented on GitHub (Mar 11, 2021): i try with https://try.gitea.io/ (1.14.0+dev-829-gbc423a1e8), and same error, here is the code : (used this repo https://try.gitea.io/elbanditest/alchi) ``` package main import ( "code.gitea.io/sdk/gitea" "fmt" "log" ) func checkError(err error) { if err != nil { log.Fatal(err) } } func main() { gclient, err := gitea.NewClient("https://try.gitea.io", gitea.SetToken("xxxxx")) checkError(err) repos, _, err := gclient.ListOrgRepos("elbanditest", gitea.ListOrgReposOptions{}) for _, data := range repos { if data.Name != "alchi" { continue } repository, _, err := gclient.EditRepo("elbanditest", data.Name, gitea.EditRepoOption{ Name: &data.Name, Description: &data.Description, Website: &data.Website, Private: &data.Private, HasIssues: &data.HasIssues, HasWiki: &data.HasWiki, DefaultBranch: &data.DefaultBranch, HasPullRequests: &data.HasPullRequests, IgnoreWhitespaceConflicts: &data.IgnoreWhitespaceConflicts, AllowMerge: &data.AllowMerge, AllowRebase: &data.AllowRebase, AllowRebaseMerge: &data.AllowRebaseMerge, AllowSquash: &data.AllowSquash, // Archived: &repoOption.Archived, }) fmt.Printf("%v, %v\n", repository, err) } } ```
Author
Owner

@zeripath commented on GitHub (Mar 11, 2021):

OK the updated panic log for master is:

2021/03/11 15:57:38 ...outers/routes/web.go:85:1() [E] PANIC: runtime error: invalid memory address or nil pointer dereference
	/usr/local/go/src/runtime/panic.go:212 (0x456e12)
		panicmem: panic(memoryError)
	/usr/local/go/src/runtime/signal_unix.go:742 (0x456c92)
		sigpanic: panicmem()
	/home/andrew/src/go/gitea/routers/api/v1/repo/repo.go:559 (0x1fd618b)
		updateBasicProperties: *opts.Private = repo.BaseRepo.IsPrivate
	/home/andrew/src/go/gitea/routers/api/v1/repo/repo.go:494 (0x1fd5904)
		Edit: if err := updateBasicProperties(ctx, opts); err != nil {
	/home/andrew/src/go/gitea/modules/web/route.go:59 (0x1e0102b)
		Wrap.func1: t(ctx)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:436 (0x19ce2ea)
		(*Mux).routeHTTP: h.ServeHTTP(w, r)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/modules/web/route.go:105 (0x1e01561)
		MiddleAPI.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/modules/context/api.go:271 (0x19e5638)
		APIContexter.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/routers/api/v1/api.go:1060 (0x2011410)
		securityHeaders.func1.1: next.ServeHTTP(resp, req)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/vendor/gitea.com/go-chi/session/session.go:256 (0x13f9acf)
		Sessioner.func1.1: next.ServeHTTP(w, req)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:70 (0x19cbf8a)
		(*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
	/home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:311 (0x19d247b)
		(*Mux).Mount.func1: handler.ServeHTTP(w, r)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:436 (0x19ce2ea)
		(*Mux).routeHTTP: h.ServeHTTP(w, r)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/routers/routes/web.go:93 (0x2039bbd)
		commonMiddlewares.func2.1: next.ServeHTTP(resp, req)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/routers/routes/base.go:37 (0x20359fb)
		LoggerHandler.func1.1: next.ServeHTTP(w, req)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/middleware/strip.go:30 (0x20304a7)
		StripSlashes.func1: next.ServeHTTP(w, r)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/middleware/realip.go:34 (0x203035c)
		RealIP.func1: h.ServeHTTP(w, r)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/routers/routes/web.go:65 (0x20396fc)
		commonMiddlewares.func1.1: next.ServeHTTP(context.NewResponse(resp), req)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:87 (0x19cbd10)
		(*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
	/home/andrew/src/go/gitea/modules/web/route.go:267 (0x1e00313)
		(*Route).ServeHTTP: r.R.ServeHTTP(w, req)
	/home/andrew/src/go/gitea/vendor/github.com/gorilla/context/context.go:141 (0x11d2713)
		ClearHandler.func1: h.ServeHTTP(w, r)
	/usr/local/go/src/net/http/server.go:2042 (0x7d5503)
		HandlerFunc.ServeHTTP: f(w, r)
	/usr/local/go/src/net/http/server.go:2843 (0x7d8b02)
		serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
	/usr/local/go/src/net/http/server.go:1925 (0x7d430c)
		(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
	/usr/local/go/src/runtime/asm_amd64.s:1374 (0x479140)
		goexit: BYTE	$0x90	// NOP
	
2021/03/11 15:57:38 Completed PATCH /api/v1/repos/forkorg/basefork 500 Internal Server Error in 26.061691ms
@zeripath commented on GitHub (Mar 11, 2021): OK the updated panic log for master is: ``` 2021/03/11 15:57:38 ...outers/routes/web.go:85:1() [E] PANIC: runtime error: invalid memory address or nil pointer dereference /usr/local/go/src/runtime/panic.go:212 (0x456e12) panicmem: panic(memoryError) /usr/local/go/src/runtime/signal_unix.go:742 (0x456c92) sigpanic: panicmem() /home/andrew/src/go/gitea/routers/api/v1/repo/repo.go:559 (0x1fd618b) updateBasicProperties: *opts.Private = repo.BaseRepo.IsPrivate /home/andrew/src/go/gitea/routers/api/v1/repo/repo.go:494 (0x1fd5904) Edit: if err := updateBasicProperties(ctx, opts); err != nil { /home/andrew/src/go/gitea/modules/web/route.go:59 (0x1e0102b) Wrap.func1: t(ctx) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:436 (0x19ce2ea) (*Mux).routeHTTP: h.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/modules/web/route.go:105 (0x1e01561) MiddleAPI.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/modules/context/api.go:271 (0x19e5638) APIContexter.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/routers/api/v1/api.go:1060 (0x2011410) securityHeaders.func1.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/vendor/gitea.com/go-chi/session/session.go:256 (0x13f9acf) Sessioner.func1.1: next.ServeHTTP(w, req) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:70 (0x19cbf8a) (*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r) /home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:311 (0x19d247b) (*Mux).Mount.func1: handler.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:436 (0x19ce2ea) (*Mux).routeHTTP: h.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/routers/routes/web.go:93 (0x2039bbd) commonMiddlewares.func2.1: next.ServeHTTP(resp, req) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/routers/routes/base.go:37 (0x20359fb) LoggerHandler.func1.1: next.ServeHTTP(w, req) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/middleware/strip.go:30 (0x20304a7) StripSlashes.func1: next.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/middleware/realip.go:34 (0x203035c) RealIP.func1: h.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/routers/routes/web.go:65 (0x20396fc) commonMiddlewares.func1.1: next.ServeHTTP(context.NewResponse(resp), req) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /home/andrew/src/go/gitea/vendor/github.com/go-chi/chi/mux.go:87 (0x19cbd10) (*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r) /home/andrew/src/go/gitea/modules/web/route.go:267 (0x1e00313) (*Route).ServeHTTP: r.R.ServeHTTP(w, req) /home/andrew/src/go/gitea/vendor/github.com/gorilla/context/context.go:141 (0x11d2713) ClearHandler.func1: h.ServeHTTP(w, r) /usr/local/go/src/net/http/server.go:2042 (0x7d5503) HandlerFunc.ServeHTTP: f(w, r) /usr/local/go/src/net/http/server.go:2843 (0x7d8b02) serverHandler.ServeHTTP: handler.ServeHTTP(rw, req) /usr/local/go/src/net/http/server.go:1925 (0x7d430c) (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req) /usr/local/go/src/runtime/asm_amd64.s:1374 (0x479140) goexit: BYTE $0x90 // NOP 2021/03/11 15:57:38 Completed PATCH /api/v1/repos/forkorg/basefork 500 Internal Server Error in 26.061691ms ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6990