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

Migration from 1.15 to 1.16 fails on webauthn table #18727

Closed
ashimokawa opened this issue Feb 11, 2022 · 6 comments · Fixed by #18739
Closed

Migration from 1.15 to 1.16 fails on webauthn table #18727

ashimokawa opened this issue Feb 11, 2022 · 6 comments · Fixed by #18739
Labels
Milestone

Comments

@ashimokawa
Copy link
Contributor

Gitea Version

1.16.1

Git Version

2.30.2

Operating System

Debian 11

How are you running Gitea?

Self-compiled from https://codeberg.org/Codeberg/gitea/src/branch/codeberg-1.16

Database

MySQL

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

When doing a test migration for coderberg.org to 1.16 in an isolated vm, the migration fails with

022/02/11 13:34:47 ...ations/migrations.go:465:Migrate() [I] Migration[207]: Add webauthn table and migrate u2f data to webauthn
2022/02/11 13:34:47 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: migrate: migration[207]: Add webauthn table and migrate u2f data to webauthn failed: Error 1406: Data too long for column 'credential_id' at row 1

The credential_id is a varchar(255) column.
Relaxing the sql mode would probably work but truncate the data, probably leading to u2f failing for affected users

(Might be related to #18477)

Screenshots

No response

@lunny lunny added the type/bug label Feb 11, 2022
@lunny lunny added this to the 1.16.2 milestone Feb 11, 2022
@zeripath
Copy link
Contributor

Duplicate #18477

@zeripath zeripath added issue/duplicate The issue has already been reported. and removed type/bug labels Feb 11, 2022
@ashimokawa
Copy link
Contributor Author

@zeripath

How is this a duplicate? This is a bug report about a failed database migration.

@zeripath zeripath reopened this Feb 11, 2022
@zeripath
Copy link
Contributor

Sorry I apologise I misread your message.

What db are you using?

@ashimokawa
Copy link
Contributor Author

@zeripath

mariadb 10.5 is the database.
The column credential_id in the newly created webauthn table is created as a varchar(255) column which is obviously too small for what is being migrated from the u2f table, so the migration fails.

The migration would probably "work" if chosing another sql_mode which allows just overflowing columns to be truncated - which then would break webauthn for affected users. That's why I pointed to the other issue which might be related - a seemingly okay migration with truncation.

@zeripath zeripath added type/bug and removed issue/duplicate The issue has already been reported. labels Feb 12, 2022
zeripath added a commit to zeripath/gitea that referenced this issue Feb 12, 2022
Unfortunately credentialIDs in u2f are 255 bytes long which with base32 encoding
becomes 408 bytes. The default size of a xorm string field is only a VARCHAR(255)

This problem is not apparent on SQLite because strings get mapped to TEXT there.

Fix go-gitea#18727

Signed-off-by: Andrew Thornton <art27@cantab.net>
@fnetX
Copy link
Contributor

fnetX commented Feb 12, 2022

@christiaangoossens You mean after updating to Gitea 1.16.1 or specifically to the mentioned PR? If the former, this is unlikely related to this issue, please check the other open issues or create a new one. Or check the configuration and changelog about breaking changes.

@christiaangoossens
Copy link

@fnetX My issue seemed to be related due to the very similar scenario and that I saw that same migration error happen, but as it's solved and probably had more to do with my outdated config, I have removed the comment. Thanks for your comment!

zeripath added a commit that referenced this issue Feb 13, 2022
)

Unfortunately credentialIDs in u2f are 255 bytes long which with base32 encoding
becomes 408 bytes. The default size of a xorm string field is only a VARCHAR(255)

This problem is not apparent on SQLite because strings get mapped to TEXT there.

Fix #18727

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this issue Feb 13, 2022
…gitea#18739)

Backport go-gitea#18739

Unfortunately credentialIDs in u2f are 255 bytes long which with base32 encoding
becomes 408 bytes. The default size of a xorm string field is only a VARCHAR(255)

This problem is not apparent on SQLite because strings get mapped to TEXT there.

Fix go-gitea#18727

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit that referenced this issue Feb 14, 2022
) (#18756)

* Increase the size of the webauthn_credential credential_id field (#18739)

Backport #18739

Unfortunately credentialIDs in u2f are 255 bytes long which with base32 encoding
becomes 408 bytes. The default size of a xorm string field is only a VARCHAR(255)

This problem is not apparent on SQLite because strings get mapped to TEXT there.

Fix #18727

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Ignore the migrate if u2f_registration is not exist (#18760)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Chianina pushed a commit to Chianina/gitea that referenced this issue Mar 28, 2022
…gitea#18739)

Unfortunately credentialIDs in u2f are 255 bytes long which with base32 encoding
becomes 408 bytes. The default size of a xorm string field is only a VARCHAR(255)

This problem is not apparent on SQLite because strings get mapped to TEXT there.

Fix go-gitea#18727

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
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.

5 participants