mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
Azure AD/Oauth2 - Link External Account operation fails due to MS SQL database error. #10901
Open
opened 2025-11-02 09:21:36 -06:00 by GiteaMirror
·
19 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16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2
v1.3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#10901
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @abjoseph on GitHub (May 23, 2023).
Description
When attempting to Link an external account as shown in the screenshot below (1st screenshot), I'm getting a HTTP 500 error (2nd screenshot). Upon looking at the logs, I found the following:
Edit/Update: I tested the exact same setup with a MySQL and SQLite database, and it worked as expected. The issue has been narrowed down to some configuration issue when Gitea is backed by a MS SQL database.
Gitea Version
1.19.3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
1st Screenshot
2nd Screenshot
Git Version
2.40.0
Operating System
Ubuntu 20.04.6 LTS
How are you running Gitea?
Gitea is ran as a service per the docs:
Database
MSSQL
@abjoseph commented on GitHub (May 28, 2023):
@GiteaBot Is anyone available to confirm my report and look into this?
@wxiaoguang commented on GitHub (May 29, 2023):
GiteaBot doesn't have ability to do that ....
Could it be caused by some of these information from your external account is too long?
@abjoseph commented on GitHub (May 29, 2023):
Hi @wxiaoguang, that is entirely possible, but I also tested the exact same setup with both SQLite and MySQL and both worked as-is without any issue. Given that the setup works with other supported databases, shouldn't we be adjusting MSSQL configuration to match Gitea's requirements that is already present in other DBMS? If not, then I don't think we can honestly list MSSQL as a fully supported database.
@wxiaoguang commented on GitHub (May 29, 2023):
I just would like to confirm that it's caused by the "length limitation".
If there is a clear clue for the bug, then there could be a fix for it. Otherwise I am not using MSSQL, so I haven't spent time on reproducing it .....
@abjoseph commented on GitHub (May 29, 2023):
@wxiaoguang, understood. Which table are these fields in? I'll take a look and experiment with what might be causing the error. Also, do you know if there is a way to have the logs show more information other than what I included in the initial post?
@wxiaoguang commented on GitHub (May 29, 2023):
The table name is
external_login_user.To get more logs: https://docs.gitea.com/help/seek-help , section 2 : logs.
@abjoseph commented on GitHub (May 29, 2023):
@wxiaoguang. Ok, so I found the discrepancy and the source of the issue. As your screenshot above shows, the
access_token,access_token_secretandrefresh_tokenare each configured with thetextdatatype which in mysql which gives a maximum length of 65,535 characters. However, in MSSQL those same fields are configured withvarchar(255)as shown below and that size limitation causes an issue for the access_token, which appears to be a JWT token and is much larger than 255 characters.P.S - Also, we might want to consider improving or at the very least, adding a line entry from the functions that initiate the DB calls. I say this because, despite enabling "LOG_SQL=true", I didn't get any additional output or info. This was confirmed when I was digging through the code for the location of the db call that writes to this table, I noticed that it simply returns the error. I know this is more or less idiomatic go coding style but it sometimes makes for harder debugging.
@wxiaoguang commented on GitHub (May 29, 2023):
Can you confirm that if you alter these columns manually, then the OAuth2 could work?
And ...are you running an old instance (upgraded from an old instance) ? I can see that these fields have been changed to
TEXTby #8554 (v1.11)@abjoseph commented on GitHub (May 29, 2023):
Hi @wxiaoguang, I can confirm that altering the columns manually to varchar(max) does resolve the OAuth2 account linking issue. Also, I can confirm that I am running the latest, 1.19.3 (2nd screenshot)
1st Screenhot
2nd Screenhot
@abjoseph commented on GitHub (May 29, 2023):
@wxiaoguang, do you know if that Issue you linked was just for MySQL DB engine or for all. I ask because, TEXT datatype does not exist in MSSQL and the reference to TEXT datatype would imply this issue was focused on MYSQL.
@wxiaoguang commented on GitHub (May 29, 2023):
The Gitea's database system is supported by XORM, so maybe there are some tricks. Could @lunny help to confirm the TEXT behavior?
@abjoseph commented on GitHub (May 29, 2023):
@wxiaoguang, I stand corrected. MSSQL does support a
textdatatype, see here but it is being deprecated and will be removed as noted in the callout; That begs the question of what XORM maps to when it runs migrations.@abjoseph commented on GitHub (Jun 6, 2023):
@delvh, do you know if this will be added to the next point release? It is a confirmed bug.
@delvh commented on GitHub (Jun 6, 2023):
Well… I don't see a bugfix PR yet, so no?
Post one (and get it merged), then we can backport the fix.
@abjoseph commented on GitHub (Jun 7, 2023):
@delvh, are you saying the core team does not have the expertise or env to replicate and fix this issue? Is MSSQL officially supported or was that a community contribution?
@lunny commented on GitHub (Jun 7, 2023):
I think it's a column size problem. I will reproduce it and try to send a PR.
@Zettat123 commented on GitHub (Jun 7, 2023):
Hi @abjoseph , is your Gitea instance upgraded from an old version? I tested Gitea v1.19.3 with mssql and saw that those columns have been set to
nvarchar(max)datatype.@abjoseph commented on GitHub (Jun 7, 2023):
Hi @Zettat123, that's correct. I have been upgrading since version 1.12.2. If this is just a case of an outdated schema, should just I proceed in manually changing those columns to nvarchar(MAX) and close this issue?
However, I'm a little concerned that there might be other tables with outdated schema settings; also, I wonder if there were failed migrations during one of those upgrades and I didn't notice or whether there is some reason/limitation of the XORM library that it wasn't able to update those columns.
@Zettat123 commented on GitHub (Jun 8, 2023):
@abjoseph Thanks for your bug report. It should be caused by the failure of migration. When you encounter similar problems, you can manually set the data type to
nvarchar(MAX). And we will try to add a newgitea doctorcommand to fix this datatype issue.