Failed to create OpenID Connect provider: invalid character '<' looking for beginning of value #4670

Closed
opened 2025-11-02 05:58:56 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @xeals on GitHub (Jan 17, 2020).

  • Gitea version (or commit ref): 3c07d03c03
  • Git version:
  • Operating system: Docker
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:
2020/01/17 22:34:38 .../xorm/session_raw.go:196:exec() [I] [SQL] INSERT INTO `login_source` (`type`,`name`,`is_actived`,`is_sync_enabled`,`cfg`,`created_unix`,`updated_unix`) VALUES (?, ?, ?, ?, ?, ?, ?) []interface {}{6, "openid", true, false, "{\"Provider\":\"openidConnect\",\"ClientID\":\"gitea\",\"ClientSecret\":\"41d83463-3190-46a5-8a80-0b2ca4818088\",\"OpenIDConnectAutoDiscoveryURL\":\"https://my.openid.domain\",\"CustomURLMapping\":null}", 1579260877, 1579260877} - took: 55.052153ms
2020/01/17 22:34:38 ...uth/oauth2/oauth2.go:173:createProvider() [W] Failed to create OpenID Connect Provider with name 'keycloak' with url 'https://auth.xeal.me': invalid character '<' looking for beginning of value                                                                           
2020/01/17 22:34:38 .../xorm/session_raw.go:196:exec() [I] [SQL] DELETE FROM `login_source` WHERE `id`=? AND `type`=? AND `name`=? AND `cfg`=? AND `created_unix`=? AND `updated_unix`=? []interface {}{3, 6, "openid", (*models.OAuth2Config)(0xc0044fa820), 1579260877, 1579260877} - took: 22.293 636µs                                                                                                                                                                                                                                                                                                                      
2020/01/17 22:34:38 ...dels/login_source.go:323:CreateLoginSource() [E] CreateLoginSource: Error while wrapOpenIDConnectInitializeError: sql: converting argument $4 type: unsupported type models.OAuth2Config, a struct                                                                          
2020/01/17 22:34:38 ...uters/admin/auths.go:264:NewAuthSourcePost() [E] CreateSource: Failed to initialize OpenID Connect Provider with name 'openid' with url 'https://my.openid.domain': invalid character '<' looking for beginning of value

Description

Adding an OpenID provider ends up with the above error and redirects to an internal server error page (https://my.gitea.domain/admin/auths/new). From experience I know that if I stop it the server will also fail to start again due to this same error.

Originally created by @xeals on GitHub (Jan 17, 2020). - Gitea version (or commit ref): 3c07d03c0388d3b86138572401281b51f2db9282 - Git version: - Operating system: Docker - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ``` 2020/01/17 22:34:38 .../xorm/session_raw.go:196:exec() [I] [SQL] INSERT INTO `login_source` (`type`,`name`,`is_actived`,`is_sync_enabled`,`cfg`,`created_unix`,`updated_unix`) VALUES (?, ?, ?, ?, ?, ?, ?) []interface {}{6, "openid", true, false, "{\"Provider\":\"openidConnect\",\"ClientID\":\"gitea\",\"ClientSecret\":\"41d83463-3190-46a5-8a80-0b2ca4818088\",\"OpenIDConnectAutoDiscoveryURL\":\"https://my.openid.domain\",\"CustomURLMapping\":null}", 1579260877, 1579260877} - took: 55.052153ms 2020/01/17 22:34:38 ...uth/oauth2/oauth2.go:173:createProvider() [W] Failed to create OpenID Connect Provider with name 'keycloak' with url 'https://auth.xeal.me': invalid character '<' looking for beginning of value 2020/01/17 22:34:38 .../xorm/session_raw.go:196:exec() [I] [SQL] DELETE FROM `login_source` WHERE `id`=? AND `type`=? AND `name`=? AND `cfg`=? AND `created_unix`=? AND `updated_unix`=? []interface {}{3, 6, "openid", (*models.OAuth2Config)(0xc0044fa820), 1579260877, 1579260877} - took: 22.293 636µs 2020/01/17 22:34:38 ...dels/login_source.go:323:CreateLoginSource() [E] CreateLoginSource: Error while wrapOpenIDConnectInitializeError: sql: converting argument $4 type: unsupported type models.OAuth2Config, a struct 2020/01/17 22:34:38 ...uters/admin/auths.go:264:NewAuthSourcePost() [E] CreateSource: Failed to initialize OpenID Connect Provider with name 'openid' with url 'https://my.openid.domain': invalid character '<' looking for beginning of value ``` ## Description Adding an OpenID provider ends up with the above error and redirects to an internal server error page (https://my.gitea.domain/admin/auths/new). From experience I know that if I stop it the server will also fail to start again due to this same error.
Author
Owner

@xeals commented on GitHub (Jan 18, 2020):

I've found out that I was using the wrong auto discovery URL, so user error. On the other hand, some feedback on whether the URL is correct (like checking the response of the URL to see that it does return something that looks like a .well-known/openid-configuration) rather than blindly accepting the URL would be a big improvement in user experience.

@xeals commented on GitHub (Jan 18, 2020): I've found out that I was using the wrong auto discovery URL, so user error. On the other hand, some feedback on whether the URL is correct (like checking the response of the URL to see that it *does* return something that looks like a `.well-known/openid-configuration`) rather than blindly accepting the URL would be a big improvement in user experience.
Author
Owner

@zig commented on GitHub (Sep 26, 2020):

Hi, I just got hit by the same issue. Is there any official way to clean up the database after this happens ? Entering a wrong url in a configuration field of the admin interface should not render the whole installation un-startable. This bug surely should not have been closed.

@zig commented on GitHub (Sep 26, 2020): Hi, I just got hit by the same issue. Is there any official way to clean up the database after this happens ? Entering a wrong url in a configuration field of the admin interface should not render the whole installation un-startable. This bug surely should not have been closed.
Author
Owner

@6543 commented on GitHub (Sep 26, 2020):

-> #12948

@6543 commented on GitHub (Sep 26, 2020): -> #12948
Author
Owner

@xeals commented on GitHub (Sep 27, 2020):

I solved the issue by manually dropping the row from the database (delete from login_source where id = <faulty row>, but in hindsight yes, it probably should've been kept open for visibility.

@xeals commented on GitHub (Sep 27, 2020): I solved the issue by manually dropping the row from the database (`delete from login_source where id = <faulty row>`, but in hindsight yes, it probably should've been kept open for visibility.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4670