Skip to content

[BUG][API] Issue/pr attachments return wrong download url #27204

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
mmarif4u opened this issue Sep 23, 2023 · 14 comments · Fixed by #27486
Closed

[BUG][API] Issue/pr attachments return wrong download url #27204

mmarif4u opened this issue Sep 23, 2023 · 14 comments · Fixed by #27486
Labels
Milestone

Comments

@mmarif4u
Copy link

Description

The issue attachment API return the following:

[
	{
		"id": 58540,
		"name": "Screenshot_20230919_133134.png",
		"size": 41611,
		"download_count": 16,
		"created_at": "2023-09-19T08:37:33Z",
		"uuid": "c9bf83dc-8d08-460e-9986-ee7f292bccd7",
		"browser_download_url": "https://codeberg.org/api/repos/gitnex/GitNex/releases/0/assets/58540"
	},
	{
		"id": 58541,
		"name": "Screenshot_20230919_133201.png",
		"size": 41475,
		"download_count": 17,
		"created_at": "2023-09-19T08:37:33Z",
		"uuid": "e5f07ce2-4179-43ae-81a2-09e4d319aab2",
		"browser_download_url": "https://codeberg.org/api/repos/gitnex/GitNex/releases/0/assets/58541"
	},
	{
		"id": 58542,
		"name": "Screenshot_20230919_133224.png",
		"size": 19559,
		"download_count": 16,
		"created_at": "2023-09-19T08:37:34Z",
		"uuid": "6bed5cd4-2f82-4566-bea7-605d12af498d",
		"browser_download_url": "https://codeberg.org/api/repos/gitnex/GitNex/releases/0/assets/58542"
	}
]

This is a possible bug because the browser_download_url is broken to me. This may also affect the comments attachment API too.
The browser_download_url should be a proper downloadable URL like how it is in the releases.

Gitea Version

1.20.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Codeberg and Gitea 1.20.3 for testing on local setup.

https://codeberg.org/api/v1/repos/gitnex/GitNex/issues/1300/assets

Database

None

@KN4CK3R
Copy link
Member

KN4CK3R commented Sep 23, 2023

I think this was fixed in 1.21 already,

@mmarif4u
Copy link
Author

I just quickly checked 1.21 rc0 and the issue is still there.

@lunny
Copy link
Member

lunny commented Sep 23, 2023

Maybe it could be fixed by #26430 .

@mmarif4u
Copy link
Author

mmarif4u commented Oct 4, 2023

Release 1.20.5 apparently did not fix this issue as the PR mentioned by @lunny is back-ported.

@lunny
Copy link
Member

lunny commented Oct 5, 2023

The backport is #27378. That PR allow token visit web routers /{username}/{reponame}/releases/download/{vTag}/{fileName}, but looks like the API's browser_download_url wasn't changed to that router.

@lunny lunny added this to the 1.20.6 milestone Oct 6, 2023
@lunny
Copy link
Member

lunny commented Oct 7, 2023

@mmarif4u Can you help to confirm #27486 fix the problem?

@mmarif4u
Copy link
Author

mmarif4u commented Oct 7, 2023

@lunny sure. Can you point me to download a binary for linux_x64 if possible as I do not have Gitea dev setup.

@lunny
Copy link
Member

lunny commented Oct 7, 2023

@lunny sure. Can you point me to download a binary for linux_x64 if possible as I do not have Gitea dev setup.

Unfortunately there is not and if you don't need sqlite support I can build one for you.

@mmarif4u
Copy link
Author

mmarif4u commented Oct 7, 2023

Feel free to share, I can set it up with any other db like MySQL or MariaDB even though I use sqlite for testing.

@lunny
Copy link
Member

lunny commented Oct 7, 2023

Feel free to share, I can set it up with any other db like MySQL or MariaDB even though I use sqlite for testing.

What's your favorite OS?

@mmarif4u
Copy link
Author

mmarif4u commented Oct 7, 2023

I work on Manjaro mostly.

@lunny
Copy link
Member

lunny commented Oct 8, 2023

https://gitea.com/lunny/packages/raw/branch/main/gitea-27486.zip

@mmarif4u
Copy link
Author

mmarif4u commented Oct 8, 2023

Thanks. I have tested it and the URL seems to be the same as web version now.

domain.com/attachments/81030792-78fd-4277-bf6f-6930bc80d618 which works for public files. For private repository files, I have tested with passing token as query param and it worked also.

Haven't tested with token as header for private repositories. But maybe that is out of scope or not a needed thing right now.

All good now.

@lunny
Copy link
Member

lunny commented Oct 8, 2023

Thanks. I have tested it and the URL seems to be the same as web version now.

domain.com/attachments/81030792-78fd-4277-bf6f-6930bc80d618 which works for public files. For private repository files, I have tested with passing token as query param and it worked also.

Haven't tested with token as header for private repositories. But maybe that is out of scope or not a needed thing right now.

All good now.

Yes, since web routers cannot be ignored and Github also point to a web router. I revert my previous change. Thank you for your confirmation.

silverwind pushed a commit that referenced this issue Oct 11, 2023
Backport #27486 by @lunny

Fix #27204

This PR allows `/<username>/<reponame>/attachments/<uuid>` access with
personal access token and also changed attachments API download url to
it so it can be download correctly.

Co-authored-by: Lunny Xiao <[email protected]>
silverwind pushed a commit that referenced this issue Oct 11, 2023
Backport #27486 by @lunny

Fix #27204

This PR allows `/<username>/<reponame>/attachments/<uuid>` access with
personal access token and also changed attachments API download url to
it so it can be download correctly.

Co-authored-by: Lunny Xiao <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2023
project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-as-gitea-fork that referenced this issue Jan 23, 2025
Backport go-gitea#27486 by @lunny

Fix go-gitea#27204

This PR allows `/<username>/<reponame>/attachments/<uuid>` access with
personal access token and also changed attachments API download url to
it so it can be download correctly.

Co-authored-by: Lunny Xiao <[email protected]>
(cherry picked from commit 7b96f71)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants