Skip to content

Commit 81e5699

Browse files
authored
modified error code for returned errors from SPIRE (#368)
Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>
1 parent fa298eb commit 81e5699

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

api/agent/server.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (s *Server) healthcheck(w http.ResponseWriter, r *http.Request) {
7575
ret, err := s.SPIREHealthcheck(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
7676
if err != nil {
7777
emsg := fmt.Sprintf("Error: %v", err.Error())
78-
retError(w, emsg, http.StatusBadRequest)
78+
retError(w, emsg, http.StatusInternalServerError)
7979
return
8080
}
8181

@@ -96,7 +96,7 @@ func (s *Server) debugServer(w http.ResponseWriter, r *http.Request) {
9696
ret, err := s.DebugServer(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
9797
if err != nil {
9898
emsg := fmt.Sprintf("Error: %v", err.Error())
99-
retError(w, emsg, http.StatusBadRequest)
99+
retError(w, emsg, http.StatusInternalServerError)
100100
return
101101
}
102102

@@ -137,7 +137,7 @@ func (s *Server) agentList(w http.ResponseWriter, r *http.Request) {
137137
ret, err := s.ListAgents(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
138138
if err != nil {
139139
emsg := fmt.Sprintf("Error: %v", err.Error())
140-
retError(w, emsg, http.StatusBadRequest)
140+
retError(w, emsg, http.StatusInternalServerError)
141141
return
142142
}
143143

@@ -181,7 +181,7 @@ func (s *Server) agentBan(w http.ResponseWriter, r *http.Request) {
181181
err = s.BanAgent(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
182182
if err != nil {
183183
emsg := fmt.Sprintf("Error listing agents: %v", err.Error())
184-
retError(w, emsg, http.StatusBadRequest)
184+
retError(w, emsg, http.StatusInternalServerError)
185185
return
186186
}
187187

@@ -226,7 +226,7 @@ func (s *Server) agentDelete(w http.ResponseWriter, r *http.Request) {
226226
err = s.DeleteAgent(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
227227
if err != nil {
228228
emsg := fmt.Sprintf("Error listing agents: %v", err.Error())
229-
retError(w, emsg, http.StatusBadRequest)
229+
retError(w, emsg, http.StatusInternalServerError)
230230
return
231231
}
232232

@@ -267,7 +267,7 @@ func (s *Server) agentCreateJoinToken(w http.ResponseWriter, r *http.Request) {
267267
ret, err := s.CreateJoinToken(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
268268
if err != nil {
269269
emsg := fmt.Sprintf("Error: %v", err.Error())
270-
retError(w, emsg, http.StatusBadRequest)
270+
retError(w, emsg, http.StatusInternalServerError)
271271
return
272272
}
273273

@@ -308,7 +308,7 @@ func (s *Server) entryList(w http.ResponseWriter, r *http.Request) {
308308
ret, err := s.ListEntries(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
309309
if err != nil {
310310
emsg := fmt.Sprintf("Error: %v", err.Error())
311-
retError(w, emsg, http.StatusBadRequest)
311+
retError(w, emsg, http.StatusInternalServerError)
312312
return
313313
}
314314

@@ -349,7 +349,7 @@ func (s *Server) entryCreate(w http.ResponseWriter, r *http.Request) {
349349
ret, err := s.BatchCreateEntry(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
350350
if err != nil {
351351
emsg := fmt.Sprintf("Error: %v", err.Error())
352-
retError(w, emsg, http.StatusBadRequest)
352+
retError(w, emsg, http.StatusInternalServerError)
353353
return
354354
}
355355

@@ -390,7 +390,7 @@ func (s *Server) entryDelete(w http.ResponseWriter, r *http.Request) {
390390
ret, err := s.BatchDeleteEntry(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
391391
if err != nil {
392392
emsg := fmt.Sprintf("Error: %v", err.Error())
393-
retError(w, emsg, http.StatusBadRequest)
393+
retError(w, emsg, http.StatusInternalServerError)
394394
return
395395
}
396396

0 commit comments

Comments
 (0)