Skip to content

Commit 16c6209

Browse files
fsaminbnjjj
authored andcommitted
fix(api): returns 404 error when X-Cds-Username is not found (#2922)
* fix(api): returns 404 error when X-Cds-Username is not found * fix
1 parent dafa2af commit 16c6209

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

engine/api/application.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package api
22

33
import (
44
"context"
5+
"database/sql"
56
"fmt"
67
"io/ioutil"
78
"net/http"
@@ -45,6 +46,9 @@ func (api *API) getApplicationsHandler() Handler {
4546
//Load the specific user
4647
u, err = user.LoadUserWithoutAuth(api.mustDB(), requestedUserName)
4748
if err != nil {
49+
if err == sql.ErrNoRows {
50+
return sdk.ErrUserNotFound
51+
}
4852
return sdk.WrapError(err, "getApplicationsHandler> unable to load user '%s'", requestedUserName)
4953
}
5054
if err := loadUserPermissions(api.mustDB(), api.Cache, u); err != nil {

sdk/error.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ var (
148148
ErrWorkerModelNoAdmin = Error{ID: 133, Status: http.StatusForbidden}
149149
ErrWorkerModelNoPattern = Error{ID: 134, Status: http.StatusForbidden}
150150
ErrJobNotBooked = Error{ID: 135, Status: http.StatusBadRequest}
151+
ErrUserNotFound = Error{ID: 136, Status: http.StatusNotFound}
151152
)
152153

153154
var errorsAmericanEnglish = map[int]string{
@@ -284,6 +285,7 @@ var errorsAmericanEnglish = map[int]string{
284285
ErrWorkerModelNoAdmin.ID: "Forbidden: you are neither a CDS administrator or the administrator for the group in which you want to create the worker model",
285286
ErrWorkerModelNoPattern.ID: "Forbidden: you must select a pattern of configuration scrips. If you have specific needs, please contact a CDS administrator",
286287
ErrJobNotBooked.ID: "Job already released",
288+
ErrUserNotFound.ID: "User not found",
287289
}
288290

289291
var errorsFrench = map[int]string{
@@ -420,6 +422,7 @@ var errorsFrench = map[int]string{
420422
ErrWorkerModelNoAdmin.ID: "Accès refusé: vous n'êtes ni un administrateur CDS ni un administrateur du groupe pour lequel vous tentez de créer votre modèle",
421423
ErrWorkerModelNoPattern.ID: "Accès refusé: vous devez obligatoirement sélectionner un pattern de script de configuration. Si vous souhaitez ajouter un pattern particulier, veuillez contacter un administrateur CDS",
422424
ErrJobNotBooked.ID: "Le job est déjà libéré",
425+
ErrUserNotFound.ID: "Utilisateur non trouvé",
423426
}
424427

425428
var errorsLanguages = []map[int]string{

0 commit comments

Comments
 (0)