500 Error in Empty repository #4126

Closed
opened 2025-11-02 05:39:19 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @RelicOfTesla on GitHub (Oct 16, 2019).

  • Gitea version (or commit ref): 1.10rc1 ref: db0d4ffdc7
  • Git version:
  • Operating system: win7
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

step1. New/Create Repository
step2. http://xxxxx:3000/xxxx/xxxx/issues/new
or /xxxx/xxxx/settings/hooks/git
response 500 error

...

Screenshots

Originally created by @RelicOfTesla on GitHub (Oct 16, 2019). - Gitea version (or commit ref): 1.10rc1 ref: db0d4ffdc7d0800b7785beddee4a715b1f7589bd - Git version: - Operating system: win7 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [ ] Not relevant - Log gist: ## Description step1. New/Create Repository step2. http://xxxxx:3000/xxxx/xxxx/issues/new or /xxxx/xxxx/settings/hooks/git response 500 error ... ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/bug label 2025-11-02 05:39:19 -06:00
Author
Owner

@zeripath commented on GitHub (Oct 16, 2019):

It would be helpful to get the log in cases like this, however it appears simple to replicate.

When trying the /issues/new endpoint I get:

2019/10/16 10:20:54 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference
	/usr/lib/go-1.13/src/runtime/panic.go:199 (0x452b4b)
		panicmem: panic(memoryError)
	/usr/lib/go-1.13/src/runtime/signal_unix.go:394 (0x452988)
		sigpanic: panicmem()
	/home/andrew/go/src/code.gitea.io/gitea/modules/git/repo_commit.go:22 (0x954e85)
		(*Repository).GetRefCommitID: ref, err := repo.gogitRepo.Reference(plumbing.ReferenceName(name), true)
	/home/andrew/go/src/code.gitea.io/gitea/modules/git/repo_commit.go:39 (0x9565c8)
		(*Repository).GetBranchCommitID: return repo.GetRefCommitID(BranchPrefix + name)
	/home/andrew/go/src/code.gitea.io/gitea/modules/git/repo_commit.go:149 (0x956571)
		(*Repository).GetBranchCommit: commitID, err := repo.GetBranchCommitID(name)
	/home/andrew/go/src/code.gitea.io/gitea/routers/repo/issue.go:385 (0x125c0d3)
		getFileContentFromDefaultBranch: ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
	/home/andrew/go/src/code.gitea.io/gitea/routers/repo/issue.go:412 (0x125c1cb)
		setTemplateIfExists: content, found := getFileContentFromDefaultBranch(ctx, filename)
	/home/andrew/go/src/code.gitea.io/gitea/routers/repo/issue.go:442 (0x125c717)
		NewIssue: setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates)
	/usr/lib/go-1.13/src/reflect/value.go:460 (0x49dea5)
	...

And on /settings/hook/git:

2019/10/16 10:22:31 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference
	/usr/lib/go-1.13/src/runtime/panic.go:199 (0x452b4b)
		panicmem: panic(memoryError)
	/usr/lib/go-1.13/src/runtime/signal_unix.go:394 (0x452988)
		sigpanic: panicmem()
	/home/andrew/go/src/code.gitea.io/gitea/routers/repo/setting.go:685 (0x1297406)
		GitHooks: hooks, err := ctx.Repo.GitRepo.Hooks()
	/home/andrew/go/src/code.gitea.io/gitea/routers/repo/setting.go:685 (0x12973fa)
		GitHooks: hooks, err := ctx.Repo.GitRepo.Hooks()
	/usr/lib/go-1.13/src/reflect/value.go:460 (0x49dea5)
		Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
	/usr/lib/go-1.13/src/reflect/value.go:321 (0x49d663)
		Value.Call: return v.call("Call", in)
	/home/andrew/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9b1d79)
		(*injector).callInvoke: return reflect.ValueOf(f).Call(in), nil
	/home/andrew/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9b1729)
		(*injector).Invoke: return inj.callInvoke(f, t, t.NumIn())
	/home/andrew/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e18c8)
		(*Context).run: vals, err := c.Invoke(c.handler())
	/home/andrew/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x10db6d1)
		(*Context).Next: c.run()
@zeripath commented on GitHub (Oct 16, 2019): It would be helpful to get the log in cases like this, however it appears simple to replicate. When trying the /issues/new endpoint I get: ``` 2019/10/16 10:20:54 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference /usr/lib/go-1.13/src/runtime/panic.go:199 (0x452b4b) panicmem: panic(memoryError) /usr/lib/go-1.13/src/runtime/signal_unix.go:394 (0x452988) sigpanic: panicmem() /home/andrew/go/src/code.gitea.io/gitea/modules/git/repo_commit.go:22 (0x954e85) (*Repository).GetRefCommitID: ref, err := repo.gogitRepo.Reference(plumbing.ReferenceName(name), true) /home/andrew/go/src/code.gitea.io/gitea/modules/git/repo_commit.go:39 (0x9565c8) (*Repository).GetBranchCommitID: return repo.GetRefCommitID(BranchPrefix + name) /home/andrew/go/src/code.gitea.io/gitea/modules/git/repo_commit.go:149 (0x956571) (*Repository).GetBranchCommit: commitID, err := repo.GetBranchCommitID(name) /home/andrew/go/src/code.gitea.io/gitea/routers/repo/issue.go:385 (0x125c0d3) getFileContentFromDefaultBranch: ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch) /home/andrew/go/src/code.gitea.io/gitea/routers/repo/issue.go:412 (0x125c1cb) setTemplateIfExists: content, found := getFileContentFromDefaultBranch(ctx, filename) /home/andrew/go/src/code.gitea.io/gitea/routers/repo/issue.go:442 (0x125c717) NewIssue: setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates) /usr/lib/go-1.13/src/reflect/value.go:460 (0x49dea5) ... ``` And on /settings/hook/git: ``` 2019/10/16 10:22:31 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference /usr/lib/go-1.13/src/runtime/panic.go:199 (0x452b4b) panicmem: panic(memoryError) /usr/lib/go-1.13/src/runtime/signal_unix.go:394 (0x452988) sigpanic: panicmem() /home/andrew/go/src/code.gitea.io/gitea/routers/repo/setting.go:685 (0x1297406) GitHooks: hooks, err := ctx.Repo.GitRepo.Hooks() /home/andrew/go/src/code.gitea.io/gitea/routers/repo/setting.go:685 (0x12973fa) GitHooks: hooks, err := ctx.Repo.GitRepo.Hooks() /usr/lib/go-1.13/src/reflect/value.go:460 (0x49dea5) Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset)) /usr/lib/go-1.13/src/reflect/value.go:321 (0x49d663) Value.Call: return v.call("Call", in) /home/andrew/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9b1d79) (*injector).callInvoke: return reflect.ValueOf(f).Call(in), nil /home/andrew/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9b1729) (*injector).Invoke: return inj.callInvoke(f, t, t.NumIn()) /home/andrew/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e18c8) (*Context).run: vals, err := c.Invoke(c.handler()) /home/andrew/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x10db6d1) (*Context).Next: c.run() ```
Author
Owner

@zeripath commented on GitHub (Oct 16, 2019):

So the problem is that either ctx.Repo.GitRepo is nil or ctx.Repo is nil.

@zeripath commented on GitHub (Oct 16, 2019): So the problem is that either `ctx.Repo.GitRepo` is nil or `ctx.Repo` is nil.
Author
Owner

@zeripath commented on GitHub (Oct 16, 2019):

https://github.com/go-gitea/gitea/blob/1d9a1a0d456887a458fd17fef417ff9c6bdd58da/modules/context/repo.go#L417-L428

Implies that in an empty repo - ctx.Repo.GitRepo will be nil

@zeripath commented on GitHub (Oct 16, 2019): https://github.com/go-gitea/gitea/blob/1d9a1a0d456887a458fd17fef417ff9c6bdd58da/modules/context/repo.go#L417-L428 Implies that in an empty repo - `ctx.Repo.GitRepo` will be nil
Author
Owner

@zeripath commented on GitHub (Oct 16, 2019):

Simplest Solution:

  • Separate out the IsEmpty and BeingCreated bits - as I think it's possible that opening a git repo in creation would fail.
  • Return on IsEmpty after setting the gitRepo
@zeripath commented on GitHub (Oct 16, 2019): Simplest Solution: * Separate out the IsEmpty and BeingCreated bits - as I think it's possible that opening a git repo in creation would fail. * Return on IsEmpty after setting the gitRepo
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4126