Skip to content

Getting notes of a tag via API triggers panic #23357

Closed
@wiktor-k

Description

@wiktor-k
Contributor

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

Activity

self-assigned this
on Mar 8, 2023
added a commit that references this issue on Mar 8, 2023
15a1c2d
added this to the 1.19.0 milestone on Mar 8, 2023
added a commit that references this issue on Mar 8, 2023
12f277a
added a commit that references this issue on Mar 8, 2023
54c674c
locked and limited conversation to collaborators on May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @lunny@wiktor-k@Zettat123@sillyguodong

    Issue actions

      Getting notes of a tag via API triggers panic · Issue #23357 · go-gitea/gitea