-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
OpenIDConnect Error handleOAuth2SignIn() [E] EnsureLinkExternalToUser: mssql nvarchar to datetime covnersion #33640
Comments
The only "datetime" field for "external user" is gitea/models/user/external_login_user.go Line 76 in c2e23d3
At gitea/services/externalaccount/user.go Lines 75 to 82 in c2e23d3
So if you are able to add more logs and build your instance to debug, I think it need to figure out the content of "gothUser" first, I guess it's And you could enable the LOG_SQL config option to see all SQL statements to see which SQLs causes that error. |
Hi wxiaoguang, thanks for checking on this. I've some more logs here and plan to investigate more later today
|
It might also be a XORM bug due to Since the data in your log |
I made a quick test: CREATE TABLE t (a NVARCHAR(200), b DATETIME);
INSERT INTO t (a, b) VALUES (N'str', N'2025-02-19 12:29:40');
SELECT * FROM t; It seems working as expected on https://dbfiddle.uk/LF2O4lu6 . Does it work on your MSSQL instance? What's the table structure of your |
Hi wxiaoguang, your test generates the same error within MSSQL. However, when i use an ISO8601 date format (with "T" instead of space), it will work: CREATE TABLE t (a NVARCHAR(200), b DATETIME);
INSERT INTO t (a, b) VALUES (N'str', N'2025-02-19T12:29:40');
SELECT * FROM t; MS SQL Server Infos:
|
Hi wxiaoguang, I found the difference. When changing the language to english it will work with space as well (either by changing the default language of the user or setting it beforehand in the query). this will always work: SET LANGUAGE english
INSERT INTO t (a, b) VALUES (N'str5', N'2025-02-19 12:31:44'); this will always fail: SET LANGUAGE german
INSERT INTO t (a, b) VALUES (N'str5', N'2025-02-19 12:31:44'); this will always work as well: INSERT INTO t (a, b) VALUES (N'str5', N'2025-02-19T12:31:44'); |
Hmm, it's really tricky. MSSQL has too many strange behaviors ....... could you fine-tune your MSSQL server to make it work with And IIRC, using space is the ANSI SQL standard |
Changing the default language of the gitea user within MSSQL fixed it. I can't tell whether it might be feasible to handle this in the code or just add language=english as a requirement in the documentation for mssql (at least I could not find any mention of it). |
Description
We tried setting up gitea with OAuth Authentication against Citrix NetScaler as IDP. Login seems to be fine and the user is asked to link that account or create a new one. Both is resulting in an 500 server error
The relevant logs shows a conversion error while writing something to the database (mssql message is in german, sorry for that):
"...web/auth/oauth.go:340:handleOAuth2SignIn() [E] EnsureLinkExternalToUser: mssql: Bei der Konvertierung eines nvarchar-Datentyps in einen datetime-Datentyp liegt der Wert außerhalb des gültigen Bereichs."
The mssql error translates to "When converting an nvarchar data type to a datetime data type, the value is out of range."
gitea configuration for authentication source: only client id, secret and discovery url are configured
netscaler configuration for idp: client id, secret, redirect url, issuer name (iss), audience (aud) are configured
When the user authenticates the gitea server is checking the userinfo from /oauth/idp/userinfo and receives this response:
{"iss": "https://oauth.company.de", "issued_to": "https://git.company.de/user/oauth2/companyOAUTH/callback", "aud": "#clientID#", "sub": "my.name@company.de", "expires_in": 3559, "iat": 1739888790, "exp": 1739889090, "name": "my name", "given_name": "my", "family_name": "name", "initials": "myn", "preferred_username": "my name", "unique_name": "mname", "upn": "my.name@company.de"}
I assume this is not an issue with authentication but some user info which is not getting updated correctly. We have LDAP authentication in place so it must be something specific to OAuth. Maybe some value from the JWT should get updated to the database.
Any help is appreciated
Gitea Version
1.23.3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
gitea runs in docker, see https://docs.gitea.com/installation/install-with-docker
Database
None
The text was updated successfully, but these errors were encountered: