Cannot upload new file from web interface and automated backups

#1

Hello everyone,

First of all, I’m quite a bit of a noob when it comes to Git. But as I’m the one that is the less scared in server administration in my group, I’ve been hosting the git repositories for a group project.

I’m running Gogs Version: 0.11.86.0130, with mysql as a database.
All of that is running on Debian 9 Strech.

The problem is :
On a specific repository, it is impossible to upload a file through the web interface to any of the branches.
I’ve tested this on multiple accounts.
I can create a new file and commit.
I can modify a file and commit.
I can upload a file via command line and commit.

I’ve set the logs to Trace, and I can see this when uploading a file :

Template: status/404

But no 404 page on the browser, it will just return back to the repository as it was before adding the file.

I’ve tried restarting the server : did not work
I haven’t tried reinstalling the whole thing and restoring a backup. May try in a VM to see if it works.

I can provide anything that will be able to help me resolve this issue.

On another note, I can’t seem to be able to use the backup option via cron.

the crontab entry is :
0 1,9,12,15,17 * * * /home/tanguy/backupScript.sh

the script launched by cron is at follows :

#!/bin/bash

cd /home/tanguy/backupGogs && /home/tanguy/gogs/gogs/gogs backup
date > date.log

I can see the date change, but no backup is created.

Thanks for taking the time to read all of this. If you have any idea for either of the issues, I’ll be happy to test them out.

Tanguy PELADO

0 Likes

#2

Can you reproduce on https://try.gogs.io?

0 Likes

#3

This post was flagged by the community and is temporarily hidden.

0 Likes

#4

OK, so I’ve restored a backup to a virtual machine, and I can replicate this problem. Still can’t upload to the repository. This might be a repo error rather than a gogs error, but I can’t figure out why its doing that.
Just tried, temporary fix for this can be to mirror the repo to my repositories, deleting the repo from the organisation, and the mirroring back the repo from my things to the organisation.

I can provide the backup file if you want.

0 Likes

#5

I think it is because the upload request sent to a 404 URL path. Can you open the Chrome web console see the request path the browser was trying to send to?

0 Likes

#6

This post was flagged by the community and is temporarily hidden.

0 Likes

#7

Same response but succeed on try.gogs.io?

Trace is the most detailed log level. And what you received is 404, which means the Gogs router couldn’t find a handler to handle the request thus no log will be generated unfortunately.

0 Likes

#8

Same response but succeed on [Link that I cannot post for obscure reasons] ?

exactly

also, why the hell are my messages flagged ? I am doing something wrong here ?

0 Likes

#9

I guess maybe it could be your reverse proxy problem?

The system automatically flags because the user level setting something.

0 Likes

#10

What is strange is that it only happens on this repository. On everything else, it works fine. Plus restoring the backup on a VM and using localhost:3000 yielded the same results

0 Likes

#11

You mean upload the exactly the same file, only occurs problem on this particular repository?

0 Likes

#12

I mean the repository yes, sorry

0 Likes

#13

Sounds like there is something unique about this problematic repository but I don’t have any ideas right now…

0 Likes

#14

If that can help, it happened around the time we merged a branch into master.

Also, do you know why I can’t launch the gogs backup via cron ?

0 Likes

#15

I do not know, you should find your script logs, not to guess why.

0 Likes

#16

I’ll leave it here if anyone get the same problem :
Expect user git but current user is ""
For cron to be running the backup job, it has to have the same username as the one in the config file.
However, cron does not carry all environment variables. The way I got it to work is to have my cron job like this :

0 1,9-18 * * * export USER="_username_in_config_"; sh myscript.sh

Otherwise, gogs will return an error since it gets the username like that:

func CurrentUsername() string {
	curUserName := os.Getenv("USER")
	if len(curUserName) > 0 {
		return curUserName
	}

	return os.Getenv("USERNAME")
}

and since either USER and USERNAME were not defined, it was just a blank string, hence the error.
I’m surely not doing this right, but it works for me.

0 Likes

#17

Yes you should set one of these environment variables.

0 Likes

#18

alright so it happened again.

I don’t know what is causing it.

Only feature not working as of now is uploading files through web interface. Everything else works as it should.

0 Likes