Skip to content

Getting notes of a tag via API triggers panic #23357

Closed
@wiktor-k

Description

@wiktor-k

Description

Hi,

I've been experimenting with git notes and noticed that notes on tags are not properly handled. See this link: https://try.gitea.io/api/v1/repos/wiktor/dks/git/notes/v1

It triggers the following panic:

2023/03/07 11:58:58 ...common/middleware.go:71:1() [E] [640718f2] PANIC: runtime error: invalid memory address or nil pointer dereference
	/usr/lib/go/src/runtime/panic.go:260 (0x45883c)
		panicmem: panic(memoryError)
	/usr/lib/go/src/runtime/signal_unix.go:837 (0x45880c)
		sigpanic: panicmem()
	/home/wiktor/src/open-source/gitea/modules/git/tree_entry_nogogit.go:93 (0x1019cda)
		(*TreeEntry).Blob: ID:      te.ID,
	/home/wiktor/src/open-source/gitea/modules/git/notes_nogogit.go:56 (0x1019a12)
		GetNote: blob := entry.Blob()
	/home/wiktor/src/open-source/gitea/routers/api/v1/repo/notes.go:62 (0x220f0a4)
		getNote: if err := git.GetNote(ctx, ctx.Repo.GitRepo, identifier, &note); err != nil {

I think the code assumes notes are only for commits and tries to get the Tree but Tags don't have it.

Gitea Version

1.20.0+dev-101-g84a299310

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Locally and via try.gitea.io

Database

None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions