Problem with authorization in Gitea 1.15.x

Drone has limit of 500 characters to store user token in “users” table. Latest Gitea can issue token that is longer than that as result even after authorizing in drone, user session is created but old token is uses as result accessing any build will show 404 error.

Drone will log error: cannot update user: pq: value too long for type character varying(500)

I was able to fix problem on my instance by changing drone database using SQL:

alter table users alter column user_oauth_token type bytea using convert_to(user_oauth_token, 'LATIN1');
alter table users alter column user_oauth_refresh type bytea using convert_to(user_oauth_refresh, 'LATIN1');
1 Like

I ran into the same issue. I’m not sure though if it’s a good idea to change the type of a column…?
Instead I just increased the length of the character varying columns:

alter table users alter column user_oauth_token type character varying(32767);
alter table users alter column user_oauth_refresh type character varying(32767);

Please note that newer versions of Drone use blob types (bytea for postgres) for storing the auth token and refresh token (via this patch). If you have an older version of Drone, you should upgrade to the latest version of Drone and then manually update the column types as shown above. Caveat that the ALTER TABLE statement above is for postgres and will need to be adjusted if you are using sqlite or mysql.

We are positive though that the report you closed as duplicate was not related, since the issue only exists for some repositories.