loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix the wrong HTTP response status code for duplicate packages (#27480)

fix #27470
(hope there is nothing missing 😢 )

---------

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>

authored by

Nanguan Lin
KN4CK3R
and committed by
GitHub
5b6258a0 2c7b6c37

+69 -23
+1
docs/content/usage/packages/alpine.en-us.md
··· 77 77 ``` 78 78 79 79 If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. 80 + 80 81 You cannot publish a file with the same name twice to a package. You must delete the existing package file first. 81 82 82 83 The server responds with the following HTTP Status codes.
+3 -1
docs/content/usage/packages/composer.en-us.md
··· 25 25 26 26 To publish a Composer package perform a HTTP PUT operation with the package content in the request body. 27 27 The package content must be the zipped PHP project with the `composer.json` file. 28 + 28 29 You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. 29 30 30 31 ``` ··· 64 65 | HTTP Status Code | Meaning | 65 66 | ----------------- | ------- | 66 67 | `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. | 68 70 69 71 ## Configuring the package registry 70 72
+2
docs/content/usage/packages/conan.en-us.md
··· 63 63 conan upload --remote=gitea ConanPackage/1.2@gitea/final 64 64 ``` 65 65 66 + You cannot publish a file with the same name twice to a package. You must delete the existing package or file first. 67 + 66 68 The Gitea Conan package registry has full [revision](https://docs.conan.io/en/latest/versioning/revisions.html) support. 67 69 68 70 ## Install a package
+10
docs/content/usage/packages/conda.en-us.md
··· 63 63 https://gitea.example.com/api/packages/testuser/conda/package-1.0.conda 64 64 ``` 65 65 66 + If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. 67 + 66 68 You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. 69 + 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. | 67 77 68 78 ## Install a package 69 79
+10
docs/content/usage/packages/cran.en-us.md
··· 68 68 https://gitea.example.com/api/packages/testuser/cran/bin?platform=windows&rversion=4.2 69 69 ``` 70 70 71 + If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. 72 + 71 73 You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. 74 + 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. | 72 82 73 83 ## Install a package 74 84
+3 -2
docs/content/usage/packages/debian.en-us.md
··· 77 77 ``` 78 78 79 79 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. 81 82 82 83 The server responds with the following HTTP Status codes. 83 84 84 85 | HTTP Status Code | Meaning | 85 86 | ----------------- | ------- | 86 87 | `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. | 88 89 | `409 Conflict` | A package file with the same combination of parameters exists already. | 89 90 90 91 ## Delete a package
+2
docs/content/usage/packages/go.en-us.md
··· 41 41 42 42 If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. 43 43 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 + 44 46 The server responds with the following HTTP Status codes. 45 47 46 48 | HTTP Status Code | Meaning |
+8
docs/content/usage/packages/swift.en-us.md
··· 67 67 68 68 You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first. 69 69 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 + 70 78 ## Install a package 71 79 72 80 To install a Swift package from the package registry, add it in the `Package.swift` file dependencies list:
+10
docs/content/usage/packages/vagrant.en-us.md
··· 44 44 https://gitea.example.com/api/packages/testuser/vagrant/test_system/1.0.0/hyperv.box 45 45 ``` 46 46 47 + If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. 48 + 47 49 You cannot publish a box if a box of the same name, version and provider already exists. You must delete the existing package first. 50 + 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. | 48 58 49 59 ## Install a package 50 60
+1 -1
routers/api/packages/alpine/alpine.go
··· 164 164 if err != nil { 165 165 switch err { 166 166 case packages_model.ErrDuplicatePackageVersion, packages_model.ErrDuplicatePackageFile: 167 - apiError(ctx, http.StatusBadRequest, err) 167 + apiError(ctx, http.StatusConflict, err) 168 168 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 169 169 apiError(ctx, http.StatusForbidden, err) 170 170 default:
+1 -1
routers/api/packages/chef/chef.go
··· 310 310 if err != nil { 311 311 switch err { 312 312 case packages_model.ErrDuplicatePackageVersion: 313 - apiError(ctx, http.StatusBadRequest, err) 313 + apiError(ctx, http.StatusConflict, err) 314 314 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 315 315 apiError(ctx, http.StatusForbidden, err) 316 316 default:
+1 -1
routers/api/packages/composer/composer.go
··· 247 247 if err != nil { 248 248 switch err { 249 249 case packages_model.ErrDuplicatePackageVersion: 250 - apiError(ctx, http.StatusBadRequest, err) 250 + apiError(ctx, http.StatusConflict, err) 251 251 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 252 252 apiError(ctx, http.StatusForbidden, err) 253 253 default:
+1 -1
routers/api/packages/conan/conan.go
··· 415 415 if err != nil { 416 416 switch err { 417 417 case packages_model.ErrDuplicatePackageFile: 418 - apiError(ctx, http.StatusBadRequest, err) 418 + apiError(ctx, http.StatusConflict, err) 419 419 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 420 420 apiError(ctx, http.StatusForbidden, err) 421 421 default:
+1 -1
routers/api/packages/debian/debian.go
··· 189 189 if err != nil { 190 190 switch err { 191 191 case packages_model.ErrDuplicatePackageVersion, packages_model.ErrDuplicatePackageFile: 192 - apiError(ctx, http.StatusBadRequest, err) 192 + apiError(ctx, http.StatusConflict, err) 193 193 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 194 194 apiError(ctx, http.StatusForbidden, err) 195 195 default:
+1 -1
routers/api/packages/maven/maven.go
··· 363 363 if err != nil { 364 364 switch err { 365 365 case packages_model.ErrDuplicatePackageFile: 366 - apiError(ctx, http.StatusBadRequest, err) 366 + apiError(ctx, http.StatusConflict, err) 367 367 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 368 368 apiError(ctx, http.StatusForbidden, err) 369 369 default:
+1 -1
routers/api/packages/npm/npm.go
··· 214 214 if err != nil { 215 215 switch err { 216 216 case packages_model.ErrDuplicatePackageVersion: 217 - apiError(ctx, http.StatusBadRequest, err) 217 + apiError(ctx, http.StatusConflict, err) 218 218 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 219 219 apiError(ctx, http.StatusForbidden, err) 220 220 default:
+1 -1
routers/api/packages/pub/pub.go
··· 213 213 if err != nil { 214 214 switch err { 215 215 case packages_model.ErrDuplicatePackageVersion: 216 - apiError(ctx, http.StatusBadRequest, err) 216 + apiError(ctx, http.StatusConflict, err) 217 217 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 218 218 apiError(ctx, http.StatusForbidden, err) 219 219 default:
+1 -1
routers/api/packages/pypi/pypi.go
··· 177 177 if err != nil { 178 178 switch err { 179 179 case packages_model.ErrDuplicatePackageFile: 180 - apiError(ctx, http.StatusBadRequest, err) 180 + apiError(ctx, http.StatusConflict, err) 181 181 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 182 182 apiError(ctx, http.StatusForbidden, err) 183 183 default:
+1 -1
routers/api/packages/rubygems/rubygems.go
··· 258 258 if err != nil { 259 259 switch err { 260 260 case packages_model.ErrDuplicatePackageVersion: 261 - apiError(ctx, http.StatusBadRequest, err) 261 + apiError(ctx, http.StatusConflict, err) 262 262 case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize: 263 263 apiError(ctx, http.StatusForbidden, err) 264 264 default:
+1 -1
tests/integration/api_packages_chef_test.go
··· 322 322 assert.Equal(t, fmt.Sprintf("%s.tar.gz", packageVersion), pfs[0].Name) 323 323 assert.True(t, pfs[0].IsLead) 324 324 325 - uploadPackage(t, packageVersion, http.StatusBadRequest) 325 + uploadPackage(t, packageVersion, http.StatusConflict) 326 326 }) 327 327 328 328 t.Run("Download", func(t *testing.T) {
+1 -1
tests/integration/api_packages_composer_test.go
··· 112 112 113 113 req = NewRequestWithBody(t, "PUT", uploadURL, bytes.NewReader(content)) 114 114 req = AddBasicAuthHeader(req, user.Name) 115 - MakeRequest(t, req, http.StatusBadRequest) 115 + MakeRequest(t, req, http.StatusConflict) 116 116 }) 117 117 }) 118 118
+1 -1
tests/integration/api_packages_debian_test.go
··· 147 147 148 148 req = NewRequestWithBody(t, "PUT", uploadURL, createArchive(packageName, packageVersion, architecture)) 149 149 AddBasicAuthHeader(req, user.Name) 150 - MakeRequest(t, req, http.StatusBadRequest) 150 + MakeRequest(t, req, http.StatusConflict) 151 151 }) 152 152 153 153 t.Run("Download", func(t *testing.T) {
+2 -2
tests/integration/api_packages_maven_test.go
··· 50 50 defer tests.PrintCurrentTest(t)() 51 51 52 52 putFile(t, fmt.Sprintf("/%s/%s", packageVersion, filename), "test", http.StatusCreated) 53 - putFile(t, fmt.Sprintf("/%s/%s", packageVersion, filename), "test", http.StatusBadRequest) 53 + putFile(t, fmt.Sprintf("/%s/%s", packageVersion, filename), "test", http.StatusConflict) 54 54 putFile(t, "/maven-metadata.xml", "test", http.StatusOK) 55 55 56 56 pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeMaven) ··· 78 78 t.Run("UploadExists", func(t *testing.T) { 79 79 defer tests.PrintCurrentTest(t)() 80 80 81 - putFile(t, fmt.Sprintf("/%s/%s", packageVersion, filename), "test", http.StatusBadRequest) 81 + putFile(t, fmt.Sprintf("/%s/%s", packageVersion, filename), "test", http.StatusConflict) 82 82 }) 83 83 84 84 t.Run("Download", func(t *testing.T) {
+1 -1
tests/integration/api_packages_npm_test.go
··· 121 121 122 122 req := NewRequestWithBody(t, "PUT", root, strings.NewReader(buildUpload(packageVersion))) 123 123 req = addTokenAuthHeader(req, token) 124 - MakeRequest(t, req, http.StatusBadRequest) 124 + MakeRequest(t, req, http.StatusConflict) 125 125 }) 126 126 127 127 t.Run("Download", func(t *testing.T) {
+1 -1
tests/integration/api_packages_pub_test.go
··· 121 121 assert.NoError(t, err) 122 122 assert.Equal(t, int64(len(content)), pb.Size) 123 123 124 - _ = uploadFile(t, result.URL, content, http.StatusBadRequest) 124 + _ = uploadFile(t, result.URL, content, http.StatusConflict) 125 125 }) 126 126 127 127 t.Run("Download", func(t *testing.T) {
+2 -2
tests/integration/api_packages_pypi_test.go
··· 129 129 t.Run("UploadExists", func(t *testing.T) { 130 130 defer tests.PrintCurrentTest(t)() 131 131 132 - uploadFile(t, "test.whl", content, http.StatusBadRequest) 133 - uploadFile(t, "test.tar.gz", content, http.StatusBadRequest) 132 + uploadFile(t, "test.whl", content, http.StatusConflict) 133 + uploadFile(t, "test.tar.gz", content, http.StatusConflict) 134 134 }) 135 135 136 136 t.Run("Download", func(t *testing.T) {
+1 -1
tests/integration/api_packages_rubygems_test.go
··· 150 150 t.Run("UploadExists", func(t *testing.T) { 151 151 defer tests.PrintCurrentTest(t)() 152 152 153 - uploadFile(t, http.StatusBadRequest) 153 + uploadFile(t, http.StatusConflict) 154 154 }) 155 155 156 156 t.Run("Download", func(t *testing.T) {