# Gitea \<\> drone: fresh setup throws 404

**URL:** <https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588>\
**Category:** Drone Support\
**Tags:** backend\
**Created:** [October 6, 2022, 2:12pm UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588 "2022-10-06T14:12:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![thommierother](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/thommierother/32/7998_2.png) [@thommierother](https://drone.discourse.group/u/thommierother)\
**Post date:** [October 6, 2022, 2:12pm UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/1 "2022-10-06T14:12:36Z")

</div>

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](https://docs.drone.io/server/provider/gitea/). 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

---

<div class="post-metadata">

**Author:** ![Shruthikini](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/shruthikini/32/7942_2.png) [@Shruthikini](https://drone.discourse.group/u/Shruthikini)\
**Post date:** [October 7, 2022, 5:20am UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/2 "2022-10-07T05:20:27Z")

</div>

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

Thanks!

---

<div class="post-metadata">

**Author:** ![thommierother](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/thommierother/32/7998_2.png) [@thommierother](https://drone.discourse.group/u/thommierother)\
**Post date:** [October 7, 2022, 2:02pm UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/3 "2022-10-07T14:02:45Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![Shruthikini](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/shruthikini/32/7942_2.png) [@Shruthikini](https://drone.discourse.group/u/Shruthikini)\
**Post date:** [October 9, 2022, 10:50am UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/4 "2022-10-09T10:50:05Z")

</div>

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

Thanks!

---

<div class="post-metadata">

**Author:** ![Shruthikini](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/shruthikini/32/7942_2.png) [@Shruthikini](https://drone.discourse.group/u/Shruthikini)\
**Post date:** [October 10, 2022, 1:40pm UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/5 "2022-10-10T13:40:48Z")

</div>

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

Can you share the screenshot of oauth2 app in gitea?

Thanks!

---

<div class="post-metadata">

**Author:** ![thommierother](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/thommierother/32/7998_2.png) [@thommierother](https://drone.discourse.group/u/thommierother)\
**Post date:** [October 10, 2022, 2:20pm UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/6 "2022-10-10T14:20:19Z")

</div>

![grafik](https://canada1.discourse-cdn.com/flex003/uploads/testdrone/original/2X/7/72bc9894e7b6c4f485fb13dc5ce56e6d69529712.png)

---

<div class="post-metadata">

**Author:** ![Shruthikini](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/shruthikini/32/7942_2.png) [@Shruthikini](https://drone.discourse.group/u/Shruthikini)\
**Post date:** [October 10, 2022, 3:37pm UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/7 "2022-10-10T15:37:45Z")

</div>

@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!

---

<div class="post-metadata">

**Author:** ![thommierother](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/thommierother/32/7998_2.png) [@thommierother](https://drone.discourse.group/u/thommierother)\
**Post date:** [October 10, 2022, 6:48pm UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/8 "2022-10-10T18:48:39Z")

</div>

@Shruthikini Here is a log excerpt starting with the click on the “continue” button on the welcome page at [Drone CI](https://drone.netzwissen.de/welcome) , created with “docker logs --follow”

```auto
{"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

```auto
"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 ??

---

<div class="post-metadata">

**Author:** ![Shruthikini](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/shruthikini/32/7942_2.png) [@Shruthikini](https://drone.discourse.group/u/Shruthikini)\
**Post date:** [October 11, 2022, 6:27am UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/9 "2022-10-11T06:27:48Z")

</div>

@thommierother let me check and get back to you.

Thanks!

---

<div class="post-metadata">

**Author:** ![thommierother](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/thommierother/32/7998_2.png) [@thommierother](https://drone.discourse.group/u/thommierother)\
**Post date:** [October 11, 2022, 8:47am UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/10 "2022-10-11T08:47:04Z")

</div>

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 …

---

<div class="post-metadata">

**Author:** ![thommierother](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/thommierother/32/7998_2.png) [@thommierother](https://drone.discourse.group/u/thommierother)\
**Post date:** [October 24, 2022, 9:41am UTC](https://drone.discourse.group/t/gitea-drone-fresh-setup-throws-404/12588/11 "2022-10-24T09:41:31Z")

</div>

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)
