Skip to content

Failed on release migration #19425

Closed
@mopinon

Description

@mopinon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions