Skip to content

Commit 075ce35

Browse files
Should return StatusUnprocessableEntity in case of invalid API values.
1 parent 2085fa2 commit 075ce35

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

routers/api/v1/repo/repo.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -678,15 +678,15 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
678678
if opts.ExternalTrackerURL != nil {
679679
if !validation.IsValidExternalURL(*opts.ExternalTrackerURL) {
680680
err := fmt.Errorf("External tracker URL not valid")
681-
ctx.Error(http.StatusBadRequest, "Invalid external tracker URL", err)
681+
ctx.Error(http.StatusUnprocessableEntity, "Invalid external tracker URL", err)
682682
return err
683683
}
684684
config.ExternalTrackerURL = *opts.ExternalTrackerURL
685685
}
686686
if opts.ExternalTrackerFormat != nil {
687687
if len(*opts.ExternalTrackerFormat) != 0 && !validation.IsValidExternalTrackerURLFormat(*opts.ExternalTrackerFormat) {
688688
err := fmt.Errorf("External tracker URL format not valid")
689-
ctx.Error(http.StatusBadRequest, "Invalid external tracker URL format", err)
689+
ctx.Error(http.StatusUnprocessableEntity, "Invalid external tracker URL format", err)
690690
return err
691691
}
692692
config.ExternalTrackerFormat = *opts.ExternalTrackerFormat
@@ -756,7 +756,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
756756
if opts.ExternalWikiURL != nil {
757757
if !validation.IsValidExternalURL(*opts.ExternalWikiURL) {
758758
err := fmt.Errorf("External wiki URL not valid")
759-
ctx.Error(http.StatusBadRequest, "", "Invalid external wiki URL")
759+
ctx.Error(http.StatusUnprocessableEntity, "", "Invalid external wiki URL")
760760
return err
761761
}
762762
config.ExternalWikiURL = *opts.ExternalWikiURL

0 commit comments

Comments
 (0)