Skip to content

Commit 5b6258a

Browse files
lng2020KN4CK3R
andauthored
Fix the wrong HTTP response status code for duplicate packages (go-gitea#27480)
fix go-gitea#27470 (hope there is nothing missing 😢 ) --------- Co-authored-by: KN4CK3R <[email protected]>
1 parent 2c7b6c3 commit 5b6258a

27 files changed

+69
-23
lines changed

docs/content/usage/packages/alpine.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ curl --user your_username:your_password_or_token \
7777
```
7878

7979
If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password.
80+
8081
You cannot publish a file with the same name twice to a package. You must delete the existing package file first.
8182

8283
The server responds with the following HTTP Status codes.

docs/content/usage/packages/composer.en-us.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ To work with the Composer package registry, you can use [Composer](https://getco
2525

2626
To publish a Composer package perform a HTTP PUT operation with the package content in the request body.
2727
The package content must be the zipped PHP project with the `composer.json` file.
28+
2829
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
2930

3031
```
@@ -64,7 +65,8 @@ The server responds with the following HTTP Status codes.
6465
| HTTP Status Code | Meaning |
6566
| ----------------- | ------- |
6667
| `201 Created` | The package has been published. |
67-
| `400 Bad Request` | The package name and/or version are invalid or a package with the same name and version already exist. |
68+
| `400 Bad Request` | The package is invalid. |
69+
| `409 Conflict` | A package file with the same combination of parameters exists already. |
6870

6971
## Configuring the package registry
7072

docs/content/usage/packages/conan.en-us.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ For example:
6363
conan upload --remote=gitea ConanPackage/1.2@gitea/final
6464
```
6565

66+
You cannot publish a file with the same name twice to a package. You must delete the existing package or file first.
67+
6668
The Gitea Conan package registry has full [revision](https://docs.conan.io/en/latest/versioning/revisions.html) support.
6769

6870
## Install a package

docs/content/usage/packages/conda.en-us.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,18 @@ curl --user your_username:your_password_or_token \
6363
https://gitea.example.com/api/packages/testuser/conda/package-1.0.conda
6464
```
6565

66+
If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password.
67+
6668
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
6769

70+
The server responds with the following HTTP Status codes.
71+
72+
| HTTP Status Code | Meaning |
73+
| ----------------- | ------- |
74+
| `201 Created` | The package has been published. |
75+
| `400 Bad Request` | The package is invalid. |
76+
| `409 Conflict` | A package file with the same combination of parameters exists already. |
77+
6878
## Install a package
6979

7080
To install a package from the package registry, execute one of the following commands:

docs/content/usage/packages/cran.en-us.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,18 @@ curl --user your_username:your_password_or_token \
6868
https://gitea.example.com/api/packages/testuser/cran/bin?platform=windows&rversion=4.2
6969
```
7070

71+
If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password.
72+
7173
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
7274

75+
The server responds with the following HTTP Status codes.
76+
77+
| HTTP Status Code | Meaning |
78+
| ----------------- | ------- |
79+
| `201 Created` | The package has been published. |
80+
| `400 Bad Request` | The package is invalid. |
81+
| `409 Conflict` | A package file with the same combination of parameters exists already. |
82+
7383
## Install a package
7484

7585
To install a R package from the package registry, execute the following command:

docs/content/usage/packages/debian.en-us.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@ curl --user your_username:your_password_or_token \
7777
```
7878

7979
If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password.
80-
You cannot publish a file with the same name twice to a package. You must delete the existing package version first.
80+
81+
You cannot publish a package if a package of the same name, version, distribution, component and architecture already exists. You must delete the existing package first.
8182

8283
The server responds with the following HTTP Status codes.
8384

8485
| HTTP Status Code | Meaning |
8586
| ----------------- | ------- |
8687
| `201 Created` | The package has been published. |
87-
| `400 Bad Request` | The package name, version, distribution, component or architecture are invalid. |
88+
| `400 Bad Request` | The package is invalid. |
8889
| `409 Conflict` | A package file with the same combination of parameters exists already. |
8990

9091
## Delete a package

docs/content/usage/packages/go.en-us.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ curl --user your_username:your_password_or_token \
4141

4242
If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password.
4343

44+
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
45+
4446
The server responds with the following HTTP Status codes.
4547

4648
| HTTP Status Code | Meaning |

docs/content/usage/packages/swift.en-us.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ curl -X PUT --user {username}:{password} \
6767

6868
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
6969

70+
The server responds with the following HTTP Status codes.
71+
72+
| HTTP Status Code | Meaning |
73+
| ----------------- | ------- |
74+
| `201 Created` | The package has been published. |
75+
| `400 Bad Request` | The package is invalid. |
76+
| `409 Conflict` | A package file with the same combination of parameters exists already. |
77+
7078
## Install a package
7179

7280
To install a Swift package from the package registry, add it in the `Package.swift` file dependencies list:

docs/content/usage/packages/vagrant.en-us.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,18 @@ curl --user your_username:your_password_or_token \
4444
https://gitea.example.com/api/packages/testuser/vagrant/test_system/1.0.0/hyperv.box
4545
```
4646

47+
If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password.
48+
4749
You cannot publish a box if a box of the same name, version and provider already exists. You must delete the existing package first.
4850

51+
The server responds with the following HTTP Status codes.
52+
53+
| HTTP Status Code | Meaning |
54+
| ----------------- | ------- |
55+
| `201 Created` | The package has been published. |
56+
| `400 Bad Request` | The package is invalid. |
57+
| `409 Conflict` | A package with the same combination of parameters exists already. |
58+
4959
## Install a package
5060

5161
To install a box from the package registry, execute the following command:

routers/api/packages/alpine/alpine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func UploadPackageFile(ctx *context.Context) {
164164
if err != nil {
165165
switch err {
166166
case packages_model.ErrDuplicatePackageVersion, packages_model.ErrDuplicatePackageFile:
167-
apiError(ctx, http.StatusBadRequest, err)
167+
apiError(ctx, http.StatusConflict, err)
168168
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
169169
apiError(ctx, http.StatusForbidden, err)
170170
default:

0 commit comments

Comments
 (0)