Skip to content

restore-repo does not correctly load "issue foreign ID"s #22414

Open
@sybrenstuvel

Description

@sybrenstuvel

Description

In short: the struct field migration.Issue.ForeignIndex is missing a yaml:"foreign_id" annotation.

When importing a dump from YAML files via gitea restore-repo, the "foreign ID" of an issue is used to load that issue's comments (see func (r *RepositoryRestorer) GetComments(...)). On first glance this ID should be stored in issue.yml in the foreign_id field, but because there is only a JSON tag and not a YAML one, effectively Gitea is reading it from foreignindex.

This issue was introduced in fa73cbf. Where all the fields that should get an underscore in the name are annotated for both YAML and JSON, the ForeignIndex is not:

type Issue struct {
	PosterID     int64             `yaml:"poster_id" json:"poster_id"`
	PosterName   string            `yaml:"poster_name" json:"poster_name"`
	PosterEmail  string            `yaml:"poster_email" json:"poster_email"`
	// ...
	IsLocked     bool              `yaml:"is_locked" json:"is_locked"`
	// ...
	ForeignIndex int64             `json:"foreign_id"`
}

Gitea Version

1.19.0+dev-289-gb36854df3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.34.1

Operating System

No response

How are you running Gitea?

Built Gitea myself from its main branch.

Database

PostgreSQL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions