Skip to content

Error downloading release files after upgrade to 1.20.3 (HTTP code 500) #26864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mppha opened this issue Sep 1, 2023 · 12 comments · Fixed by #26883
Closed

Error downloading release files after upgrade to 1.20.3 (HTTP code 500) #26864

mppha opened this issue Sep 1, 2023 · 12 comments · Fixed by #26883
Assignees
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.

Comments

@mppha
Copy link

mppha commented Sep 1, 2023

Description

After upgrading 1.19.0 -> 1.20.3, the following error is shown when trying to download a release file:

An error occurred:

Open, open /var/lib/gitea/data/data/attachments/7/3/73bcfcc3-ab3c-42b3-9980-6f1e99312034: no such file or directory

Looking at the startup logs it seems that the attachments path is different despite using the same configuration.
Before upgrade:

...s/storage/storage.go:175:initAttachments() [I] Initialising Attachment storage with type:
 ...les/storage/local.go:45:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/attachments

After upgrade:

...s/storage/storage.go:176:initAttachments() [I] Initialising Attachment storage with type: local
...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/data/attachments

Gitea Version

1.20.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Prebuilt binary (https://dl.gitea.com/gitea/1.20.3/gitea-1.20.3-linux-amd64) on RHEL8.8 with systemd.
Service file based on https://github.com/go-gitea/gitea/blob/main/contrib/systemd/gitea.service

Database

None

@mppha mppha added the type/bug label Sep 1, 2023
@CaiCandong
Copy link
Member

Could you post the configuration information for the [attachment] section of your app.ini?

@mppha
Copy link
Author

mppha commented Sep 1, 2023

Thanks for the quick response @CaiCandong

[attachment]
ENABLE = true
PATH = data/attachments
MAX_SIZE = 100
MAX_FILES = 5

@CaiCandong
Copy link
Member

Thanks. I can also see locally that there seems to be an extra /data here.
image

@techknowlogick
Copy link
Member

PATH = data/attachments. Thanks for posting your config, could you update the PATH to be an absolute path definition (/var/lib/gitea/data/attachments)?

@techknowlogick techknowlogick added type/question Issue needs no code to be fixed, only a description on how to fix it yourself. and removed type/bug labels Sep 1, 2023
@CaiCandong
Copy link
Member

CaiCandong commented Sep 1, 2023

PATH = data/attachments. Thanks for posting your config, could you update the PATH to be an absolute path definition (/var/lib/gitea/data/attachments)?

I think this is a bug , if I don't set this field:
image
image

The default value here is not data/attachments?

@mppha
Copy link
Author

mppha commented Sep 1, 2023

@techknowlogick Changing to absolute path seems to fix the variable as seen in startup logs:

...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /var/lib/gitea/data/attachments

Older release files can now be downloaded, but newer releases fail (these seem to be stored in /var/lib/gitea/data/data):

An error occurred:

Open, open /var/lib/gitea/data/attachments/a/1/a1325050-c807-4c8c-8a8f-9ad6c18ab8c3: no such file or directory

@CaiCandong
Copy link
Member

CaiCandong commented Sep 1, 2023

You can move over manually first, which will allow your service to be available. I'm still locating this bug. @mppha

@mppha
Copy link
Author

mppha commented Sep 1, 2023

fyi, all our releases are now available after setting the config to PATH = /var/lib/gitea/data/attachments and moving all newer releases manually from /var/lib/gitea/data/data/attachments to /var/lib/gitea/data/attachments

@techknowlogick
Copy link
Member

@mppha glad to hear.
I'll keep this open while @CaiCandong does additional investigation and creates a bugfix

@CaiCandong
Copy link
Member

CaiCandong commented Sep 1, 2023

I'll keep this open while @CaiCandong does additional investigation and creates a bugfix

I asked @lunny about this, and he said that the path is relative to the AppDataPath, so maybe we should update the config docs and app.example.ini
The default configuration should be PATH=attachments (${AppDataPath}/${attachments.PATH} )
I haven't tested to see if in 1.19.0 whether the ${AppWorkPath}/${attachments.PATH}

@CaiCandong
Copy link
Member

This change was caused by #26271. Although I do not understand the code about it now, it is clear that it does that to fix a bug. But it is breaking change.
For configuration as below:

[attachment]
ENABLE = true
PATH = data/attachments
MAX_SIZE = 100
MAX_FILES = 5

@lunny
Copy link
Member

lunny commented Sep 3, 2023

I'll keep this open while @CaiCandong does additional investigation and creates a bugfix

I asked @lunny about this, and he said that the path is relative to the AppDataPath, so maybe we should update the config docs and app.example.ini The default configuration should be PATH=attachments (${AppDataPath}/${attachments.PATH} ) I haven't tested to see if in 1.19.0 whether the ${AppWorkPath}/${attachments.PATH}

Yes, this was a break change.

@CaiCandong CaiCandong self-assigned this Sep 3, 2023
KN4CK3R pushed a commit that referenced this issue Sep 3, 2023
This change was caused by #26271, for configuration as below:
```
[attachment]
ENABLE = true
PATH = data/attachments
MAX_SIZE = 100
MAX_FILES = 5
```
Before #26271, the resolved path is ${AppWorkPath}/${attachments.PATH}
(such as `/var/lib/gitea/data/attachments`)
After #26271, the resolved path is ${AppDataPath}/${attachments.PATH}
(such as `/var/lib/gitea/data/data/attachments`)


Fix  #26864
Follow #26271
CaiCandong added a commit to CaiCandong/gitea that referenced this issue Sep 3, 2023
This change was caused by go-gitea#26271, for configuration as below:
```
[attachment]
ENABLE = true
PATH = data/attachments
MAX_SIZE = 100
MAX_FILES = 5
```
Before go-gitea#26271, the resolved path is ${AppWorkPath}/${attachments.PATH}
(such as `/var/lib/gitea/data/attachments`)
After go-gitea#26271, the resolved path is ${AppDataPath}/${attachments.PATH}
(such as `/var/lib/gitea/data/data/attachments`)

Fix  go-gitea#26864
Follow go-gitea#26271
techknowlogick pushed a commit that referenced this issue Sep 3, 2023
Backport #26883 
This change was caused by #26271, for configuration as below:
```
[attachment]
ENABLE = true
PATH = data/attachments
MAX_SIZE = 100
MAX_FILES = 5
```
Before #26271, the resolved path is ${AppWorkPath}/${attachments.PATH}
(such as `/var/lib/gitea/data/attachments`)
After #26271, the resolved path is ${AppDataPath}/${attachments.PATH}
(such as `/var/lib/gitea/data/data/attachments`)

Fix #26864 Follow
#26271
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants