Oauth2 don't fly with mysql/mariadb #1776

Closed
opened 2025-11-02 04:12:55 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @agaida on GitHub (May 10, 2018).

  • Gitea version (or commit ref): latest git
  • Git version: 2.17.0
  • Operating system: debian stretch
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • [X ] Not relevant
  • Log gist:

Description

after upgrading to current git i get an

2018/05/10 15:30:48 [...itea/routers/init.go:64 GlobalInit()] [E] Failed to initialize OAuth2 support: Error 1071: Specified key was too long; max key length is 767 bytes

this is clearly a 'bug' with mariadb - gitea try to create the oauth2_ table and fails creating it because the primary key is to long, refs: https://stackoverflow.com/questions/41176482/mariadb-wont-create-table-with-large-varchar-as-primary-key

Originally created by @agaida on GitHub (May 10, 2018). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): latest git - Git version: 2.17.0 - Operating system: debian stretch - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [X ] Not relevant - Log gist: ## Description after upgrading to current git i get an ``` 2018/05/10 15:30:48 [...itea/routers/init.go:64 GlobalInit()] [E] Failed to initialize OAuth2 support: Error 1071: Specified key was too long; max key length is 767 bytes ``` this is clearly a 'bug' with mariadb - gitea try to create the oauth2_ table and fails creating it because the primary key is to long, refs: https://stackoverflow.com/questions/41176482/mariadb-wont-create-table-with-large-varchar-as-primary-key
GiteaMirror added the type/enhancement label 2025-11-02 04:12:55 -06:00
Author
Owner

@agaida commented on GitHub (May 10, 2018):

going back to v1.1.0-1167-g8d5f58d83 kind of 'solve' that for me

@agaida commented on GitHub (May 10, 2018): going back to v1.1.0-1167-g8d5f58d83 kind of 'solve' that for me
Author
Owner

@agaida commented on GitHub (May 10, 2018):

https://dev.mysql.com/doc/refman/5.5/en/charset-charsets.html - might give some hints too. So right now i 'fixed' it with

CREATE TABLE IF NOT EXISTS `oauth2_session` (`id` VARCHAR(400) PRIMARY KEY NOT NULL, `data` TEXT NULL, `created_unix` BIGINT(20) NULL, `updated_unix` BIGINT(20) NULL, `expires_unix` BIGINT(20) NULL) DEFAULT CHARSET latin1 ENGINE = myisam;

but imho this is really dirty

Edit: Hmm, innodb would work too, but such long primary keys should be considered dirty anyways - what about a hash as id?

@agaida commented on GitHub (May 10, 2018): https://dev.mysql.com/doc/refman/5.5/en/charset-charsets.html - might give some hints too. So right now i 'fixed' it with ``` CREATE TABLE IF NOT EXISTS `oauth2_session` (`id` VARCHAR(400) PRIMARY KEY NOT NULL, `data` TEXT NULL, `created_unix` BIGINT(20) NULL, `updated_unix` BIGINT(20) NULL, `expires_unix` BIGINT(20) NULL) DEFAULT CHARSET latin1 ENGINE = myisam; ``` but imho this is really dirty Edit: Hmm, innodb would work too, but such long primary keys should be considered dirty anyways - what about a hash as id?
Author
Owner

@techknowlogick commented on GitHub (May 10, 2018):

utf8mb4 doesn't work, however utf8 does. no need for latin1 or myisam.

@techknowlogick commented on GitHub (May 10, 2018): utf8mb4 doesn't work, however utf8 does. no need for latin1 or myisam.
Author
Owner

@thehowl commented on GitHub (May 10, 2018):

See #3859

@thehowl commented on GitHub (May 10, 2018): See #3859
Author
Owner

@agaida commented on GitHub (May 10, 2018):

utf8 don't work - https://github.com/go-gitea/gitea/issues/3859#issuecomment-386355900

mysql> SHOW CHARACTER SET;
+----------+-----------------------------+---------------------+--------+
| Charset  | Description                 | Default collation   | Maxlen |
+----------+-----------------------------+---------------------+--------+
| latin1   | cp1252 West European        | latin1_swedish_ci   |      1 |
| ascii    | US ASCII                    | ascii_general_ci    |      1 |
| utf8     | UTF-8 Unicode               | utf8_general_ci     |      3 |
| utf8mb4  | UTF-8 Unicode               | utf8mb4_general_ci  |      4 |
| utf16    | UTF-16 Unicode              | utf16_general_ci    |      4 |
| utf32    | UTF-32 Unicode              | utf32_general_ci    |      4 |
+----------+-----------------------------+---------------------+--------+
@agaida commented on GitHub (May 10, 2018): utf8 don't work - https://github.com/go-gitea/gitea/issues/3859#issuecomment-386355900 ``` mysql> SHOW CHARACTER SET; +----------+-----------------------------+---------------------+--------+ | Charset | Description | Default collation | Maxlen | +----------+-----------------------------+---------------------+--------+ | latin1 | cp1252 West European | latin1_swedish_ci | 1 | | ascii | US ASCII | ascii_general_ci | 1 | | utf8 | UTF-8 Unicode | utf8_general_ci | 3 | | utf8mb4 | UTF-8 Unicode | utf8mb4_general_ci | 4 | | utf16 | UTF-16 Unicode | utf16_general_ci | 4 | | utf32 | UTF-32 Unicode | utf32_general_ci | 4 | +----------+-----------------------------+---------------------+--------+ ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1776