@@ -289,7 +289,27 @@ func (p *ProxyHealth) runOnce(ctx context.Context, now time.Time) (map[uuid.UUID
289
289
case err == nil && resp .StatusCode != http .StatusOK :
290
290
// Unhealthy as we did reach the proxy but it got an unexpected response.
291
291
status .Status = Unhealthy
292
- status .Report .Errors = []string {fmt .Sprintf ("unexpected status code %d" , resp .StatusCode )}
292
+ var builder strings.Builder
293
+ // This string is shown on the UI where newlines are respected.
294
+ // This error message is not ever decoded programmatically, so keep it human-
295
+ // readable.
296
+ builder .WriteString (fmt .Sprintf ("unexpected status code %d. " , resp .StatusCode ))
297
+ builder .WriteString (fmt .Sprintf ("\n Encountered error, send a request to %q from the Coderd environment to debug this issue." , reqURL ))
298
+ err := codersdk .ReadBodyAsError (resp )
299
+ if err != nil {
300
+ var apiErr * codersdk.Error
301
+ if xerrors .As (err , & apiErr ) {
302
+ builder .WriteString (fmt .Sprintf ("\n Error Message: %s\n Error Detail: %s" , apiErr .Message , apiErr .Detail ))
303
+ for _ , v := range apiErr .Validations {
304
+ // Pretty sure this is not possible from the called endpoint, but just in case.
305
+ builder .WriteString (fmt .Sprintf ("\n \t Validation: %s=%s" , v .Field , v .Detail ))
306
+ }
307
+ } else {
308
+ builder .WriteString (fmt .Sprintf ("\n Error: %s" , err .Error ()))
309
+ }
310
+ }
311
+
312
+ status .Report .Errors = []string {builder .String ()}
293
313
case err != nil :
294
314
// Request failed, mark the proxy as unreachable.
295
315
status .Status = Unreachable
0 commit comments