Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed on release migration #19425

Closed
mopinon opened this issue Apr 19, 2022 · 3 comments · Fixed by #19510
Closed

Failed on release migration #19425

mopinon opened this issue Apr 19, 2022 · 3 comments · Fixed by #19510
Labels
Milestone

Comments

@mopinon
Copy link

mopinon commented Apr 19, 2022

Description

I use last version gitea v1.16.5 via PostgreSQL 14.2
When migrating repositories from the github, I encountered a problem: pq: value does not fit into character type varying(40)

2022/04/19 11:42:20 [625e75ec] router: completed GET /user/task/5?_csrf=6mkrOo9wzGEBk-_Z6kUI6Sx2DOY6MTY1MDM1NzYyNDMwOTM1OTMwMA for [::1]:55411, 200 OK in 2.4ms @ user/task.go:17(user.TaskStatus)
5[REALEASE migrate.go] COMMIT SIZE 45 a-string-that-is-longer-than-forty-characters
2022/04/19 11:42:22 ...ervices/task/task.go:56:handle() [E] Run task failed: pq: value does not fit into character type varying(40)
        C:/Projects/gitea/services/task/task.go:56 (0x1f64005)
        C:/Projects/gitea/modules/queue/queue_disk_channel.go:60 (0x166f721)
        C:/Projects/gitea/modules/queue/queue_channel.go:65 (0x166d41d)
        C:/Projects/gitea/modules/queue/workerpool.go:561 (0x1680a0e)
        C:/Projects/gitea/modules/queue/workerpool.go:309 (0x167f2a4)
        C:/Program Files/Go/src/runtime/asm_amd64.s:1571 (0x46cc20)

The error occurred only when the Releases checkbox was checked

In the "Releases" table, only the Sha1 field has the data type charaсter varying(40)

I was surprised that sha1 has more than 40 characters and made logs

gitea/models/migrate.go

Lines 158 to 183 in b74322d

func InsertReleases(rels ...*Release) error {
ctx, committer, err := db.TxContext()
if err != nil {
return err
}
defer committer.Close()
sess := db.GetEngine(ctx)
for _, rel := range rels {
if _, err := sess.NoAutoTime().Insert(rel); err != nil {
return err
}
if len(rel.Attachments) > 0 {
for i := range rel.Attachments {
rel.Attachments[i].ReleaseID = rel.ID
}
if _, err := sess.NoAutoTime().Insert(rel.Attachments); err != nil {
return err
}
}
}
return committer.Commit()
}

I inserted the following code between lines 166 and 167 in the above file

fmt.Println("5[REALEASE migrate.go] COMMIT SIZE", len(rel.Sha1), rel.Sha1)

I saw the following in the logs: 5[REALEASE migrate.go] COMMIT SIZE 45 a-string-that-is-longer-than-forty-characters
a-string-that-is-longer-than-forty-characters - the name of the branch from which the release was made

IIf you change the type of field in the database to text, the error disappears
It's strange, but the database eventually writes hashes of commits

I create repo for reproduce this bug

Gitea Version

v1.16.5

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

image
image
image

Git Version

git version 2.35.1.windows.2

Operating System

Windows 10

How are you running Gitea?

use gitea-1.16.5-windows-4.0-amd64.exe
For the logs I made a build for win10 according to the instructions from README.MD

Database

PostgreSQL

@mopinon mopinon changed the title Crash on release migration Failed on release migration Apr 19, 2022
@lunny lunny added this to the 1.16.6 milestone Apr 19, 2022
@6543 6543 modified the milestones: 1.16.6, 1.16.7 Apr 20, 2022
@lunny
Copy link
Member

lunny commented Apr 26, 2022

Look at the result of https://api.github.com/repos/mopinon/gitea-import-release/releases , github didn't return a commit hash but a branch name. But gitea expects a commit hash.

@mopinon
Copy link
Author

mopinon commented Apr 26, 2022

It's strange, but the database eventually writes hashes of commits

if gitea expects a commit hash, then how sha1 gets into the database? github returns the branch name.

The github documentation states that target_commitish is the branch name

commit-ish is not necessarily a commit hash https://stackoverflow.com/questions/23303549/what-are-commit-ish-and-tree-ish-in-git

@lunny
Copy link
Member

lunny commented Apr 26, 2022

OK. I think the bug is we need to get tag commit hash but not from target_commitish

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants