500 error on github OAuth2 login #381

Closed
opened 2025-11-02 03:20:53 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @morrildl on GitHub (Feb 22, 2017).

I've been tracking #679 and #26 and this morning I figured I'd give it a try. Looks like a small oversight in DB creation on init.

I created the Github OAuth2 app scope, entered the keys, etc. From logs, the OAuth2 flow completed fine, but the result 500s with this in the log:

[Macaron] 2017-02-22 09:07:00: Started GET /user/oauth2/Zomg/callback?code=86f771c0cb21e266ea46&state=7845f8a6-c638-441b-84de-a24c4dafe260 for 172.17.0.1
[Macaron] 2017-02-22 09:07:01: Completed /user/oauth2/Zomg/callback?code=86f771c0cb21e266ea46&state=7845f8a6-c638-441b-84de-a24c4dafe260 500 Internal Server Error in 979.07248ms

...and this in the UI in dev mode:

An error has occurred : pq: relation "external_login_user" does not exist

Application Version: 1.0.0+304-g29c6f32a

Looks like a database didn't get created on initialization. This is just an instance of the Dockerhub image last pushed a few hours ago.

Originally created by @morrildl on GitHub (Feb 22, 2017). I've been tracking #679 and #26 and this morning I figured I'd give it a try. Looks like a small oversight in DB creation on init. I created the Github OAuth2 app scope, entered the keys, etc. From logs, the OAuth2 flow completed fine, but the result 500s with this in the log: [Macaron] 2017-02-22 09:07:00: Started GET /user/oauth2/Zomg/callback?code=86f771c0cb21e266ea46&state=7845f8a6-c638-441b-84de-a24c4dafe260 for 172.17.0.1 [Macaron] 2017-02-22 09:07:01: Completed /user/oauth2/Zomg/callback?code=86f771c0cb21e266ea46&state=7845f8a6-c638-441b-84de-a24c4dafe260 500 Internal Server Error in 979.07248ms ...and this in the UI in dev mode: An error has occurred : pq: relation "external_login_user" does not exist Application Version: 1.0.0+304-g29c6f32a Looks like a database didn't get created on initialization. This is just an instance of [the Dockerhub image](https://hub.docker.com/r/gitea/gitea/) last pushed a few hours ago.
GiteaMirror added the type/bug label 2025-11-02 03:20:53 -06:00
Author
Owner

@morrildl commented on GitHub (Feb 22, 2017):

Possibly worth noting that in the setup wizard thing I created the instance with account registration disabled, but then enabled it after my first OAuth2 login failed with the 500, figuring that might be the cause.

@morrildl commented on GitHub (Feb 22, 2017): Possibly worth noting that in the setup wizard thing I created the instance with account registration disabled, but then enabled it after my first OAuth2 login failed with the 500, figuring that might be the cause.
Author
Owner

@strk commented on GitHub (Feb 22, 2017):

Did you test another PR before, which may have updated your database "version"
table ? That's what migration are based on...

Hint: try with a fresh database

@strk commented on GitHub (Feb 22, 2017): Did you test another PR before, which may have updated your database "version" table ? That's what migration are based on... Hint: try with a fresh database
Author
Owner

@morrildl commented on GitHub (Feb 22, 2017):

Yes, this is a 100% clean build, with a fresh database.

AFAICT the problem is that ExternalLoginUser was added to migrations, but wasn't added to the module init in models/models.go. At least, with this diff on master it's fixed, and I can log in:

diff --git a/models/models.go b/models/models.go
index 33268fa..a993e50 100644
--- a/models/models.go
+++ b/models/models.go
@@ -114,6 +114,7 @@ func init() {
                new(TwoFactor),
                new(RepoUnit),
                new(RepoRedirect),
+               new(ExternalLoginUser),
        )
 
        gonicNames := []string{"SSL", "UID"}

Happy to work that up as a PR if you like, but it'd take me a bit to get a proper fork set up to generate the PR against, etc.

Also it looks like @willemvd has another PR in flight, so assuming this is the correct fix, might be simplest to just include it in there.

@morrildl commented on GitHub (Feb 22, 2017): Yes, this is a 100% clean build, with a fresh database. AFAICT the problem is that ExternalLoginUser was added to migrations, but wasn't added to the module init in models/models.go. At least, with this diff on master it's fixed, and I can log in: diff --git a/models/models.go b/models/models.go index 33268fa..a993e50 100644 --- a/models/models.go +++ b/models/models.go @@ -114,6 +114,7 @@ func init() { new(TwoFactor), new(RepoUnit), new(RepoRedirect), + new(ExternalLoginUser), ) gonicNames := []string{"SSL", "UID"} Happy to work that up as a PR if you like, but it'd take me a bit to get a proper fork set up to generate the PR against, etc. Also it looks like @willemvd has another PR in flight, so assuming this is the correct fix, might be simplest to just include it in there.
Author
Owner

@strk commented on GitHub (Feb 22, 2017):

Good catch ! Does that then only happen on new installs ?
Please send the PR, it'll be needed anyway as nobody can
push directly to master...

@strk commented on GitHub (Feb 22, 2017): Good catch ! Does that then only happen on new installs ? Please send the PR, it'll be needed anyway as nobody can push directly to master...
Author
Owner

@strk commented on GitHub (Feb 22, 2017):

This is for @willemvd, btw

@strk commented on GitHub (Feb 22, 2017): This is for @willemvd, btw
Author
Owner

@morrildl commented on GitHub (Feb 22, 2017):

It happened to me on a new install, but I don't have an existing install to test against.

@morrildl commented on GitHub (Feb 22, 2017): It happened to me on a new install, but I don't have an existing install to test against.
Author
Owner

@willemvd commented on GitHub (Feb 22, 2017):

Will test it against a clean setup tomorrow (+- 9 hours from now :) ) and provide a PR if required like you suggested (will also have a look to fix #1015 in that same PR)

@willemvd commented on GitHub (Feb 22, 2017): Will test it against a clean setup tomorrow (+- 9 hours from now :) ) and provide a PR if required like you suggested (will also have a look to fix #1015 in that same PR)
Author
Owner

@willemvd commented on GitHub (Feb 22, 2017):

Btw , try.gitea.io is upgraded and configured against Github, so existing install is working ;)

@willemvd commented on GitHub (Feb 22, 2017): Btw , try.gitea.io is upgraded and configured against Github, so existing install is working ;)
Author
Owner

@lunny commented on GitHub (Feb 23, 2017):

@morrildl I think you are right, please send a PR

@lunny commented on GitHub (Feb 23, 2017): @morrildl I think you are right, please send a PR
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#381