Gitea <> drone: fresh setup throws 404

Hi, I just installed drone with the drone:latest container and the drone-runner-ssh_1 pipeline. gitea is version 1.17.2, oauth was set up according to Gitea | Drone. The initital login from drone to gitea throws a 404 with the following endpoint:

https://drone.netzwissen.de/gitea.netzwissen.de/login/oauth/authorize?client_id=[xxx]&redirect_uri=https%3A%2F%2Fdrone.netzwissen.de%2Flogin&response_type=code&state=[xxx]

I double checked the drone config and see no obvious error there and the older posts here about 404 do not help. Any ideas for debugging?

Thx, Thommie

Hi @thommierother can you regenerate the API key and refresh the oauth2 client secret and try again.

Thanks!

Hi Shruthi,
I did that already, two times ;-). This is the server.env (security-sensitive values are XXX-ed)

DRONE_SERVER_HOST=drone.netzwissen.de
DRONE_SERVER_PROTO=https
DRONE_GITEA_CLIENT_ID=[aaaaaaaaaaa]
DRONE_GITEA_CLIENT_SECRET=[bbbbbbbbb]
DRONE_GITEA_SERVER=gitea.netzwissen.de
DRONE_USER_CREATE=username:thommie:true,token:[cccccccc]
DRONE_USER_FILTER=thommie
DRONE_RPC_PROTO=https
DRONE_RPC_HOST=drone.netzwissen.de
DRONE_RPC_SECRET=[dddddd]
DRONE_RUNNER_CAPACITY=2

Do we have a chance to see a bit more about the 404 root cause?

@thommierother sure let me check and get back to you.

Thanks!

@thommierother it must be an issue around oauth2 app creation.

Can you share the screenshot of oauth2 app in gitea?

Thanks!

@thommierother your initial message in this loop has this URL

https://drone.netzwissen.de/gitea.netzwissen.de/login/oauth/authorize?client_id=[xxx]&redirect_uri=https%3A%2F%2Fdrone.netzwissen.de%2Flogin&response_type=code&state=[xxx]

we can see that gitea.netzwissen.de URL ends up twice.

Can you pass DRONE_LOGS_DEBUG=true to the server and see if any of the debug output shows the URL twice?

Thanks!

@Shruthikini Here is a log excerpt starting with the click on the “continue” button on the welcome page at Drone CI , created with “docker logs --follow”

{"fields.time":"2022-10-10T18:39:08Z","latency":38792,"level":"debug","method":"GET","msg":"","remote":"10.10.10.21:56370","request":
"/login","request-id":"2FxI8Ttn43b6RW4S6MiolZ589JM","time":"2022-10-10T18:39:08Z"}
{"fields.time":"2022-10-10T18:39:08Z","latency":33561,"level":"debug","method":"GET","msg":"","remote":"10.10.10.21:56372","request":
"/gitea.netzwissen.de/login/oauth/authorize?client_id=8493a5b8-417b-4460-96a3-25fe07b7cd86\u0026redirect_uri=https%3A%2F%2Fdrone.netz
wissen.de%2Flogin\u0026response_type=code\u0026state=b80704bb7b4d7c03","request-id":"2FxI8WPLYhJ3wDPbIjTUXIEwx9m","time":"2022-10-10T
18:39:08Z"}
{"level":"debug","msg":"api: authentication required","request-id":"2FxI8XDHBczBXT0ME09s1kzZKNJ","time":"2022-10-10T18:39:09Z"}
{"level":"debug","msg":"api: guest access","request-id":"2FxI8XDHBczBXT0ME09s1kzZKNJ","time":"2022-10-10T18:39:09Z"}
{"fields.time":"2022-10-10T18:39:09Z","latency":215559,"level":"debug","method":"GET","msg":"","remote":"10.10.10.21:56374","request"
:"/api/user","request-id":"2FxI8XDHBczBXT0ME09s1kzZKNJ","time":"2022-10-10T18:39:09Z"}
{"level":"debug","msg":"events: stream opened","request-id":"2FxI8byQPYagQvyauAES2Jb9b2E","time":"2022-10-10T18:39:09Z"}
{"error":"sql: no rows in result set","level":"debug","msg":"api: repository not found","name":"login","namespace":"gitea.netzwissen.
de","request-id":"2FxI8eNeSQRrihJQV8SRPh4Vmu8","time":"2022-10-10T18:39:09Z"}
{"level":"debug","msg":"api: guest access","request-id":"2FxI8eNeSQRrihJQV8SRPh4Vmu8","time":"2022-10-10T18:39:09Z"}
{"fields.time":"2022-10-10T18:39:09Z","latency":386206,"level":"debug","method":"GET","msg":"","remote":"10.10.10.21:56378","request"
:"/api/repos/gitea.netzwissen.de/login","request-id":"2FxI8eNeSQRrihJQV8SRPh4Vmu8","time":"2022-10-10T18:39:09Z"}

I don’t understand that

"error":"sql: no rows in result set",

I guess that the 404 we see is just a result of something going wrong even earlier …
Any ideas ??

@thommierother let me check and get back to you.

Thanks!

Operation in the gitea web UI is normal, same goes for all git actions through vscode. I looked into the sql database behind gitea and there is nothing “obviously wrong”, I dont know which “row” is expected here …

1 Like

Re-installation of drone and re-creating the sqlite database fixed the issue. Root cause was a space character in the client secret, (paste/copy error)

1 Like