@@ -51,7 +51,10 @@ type OAuth2Configs struct {
51
51
Github OAuth2Config
52
52
}
53
53
54
- const signedOutErrorMessage string = "You are signed out or your session has expired. Please sign in again to continue."
54
+ const (
55
+ signedOutErrorMessage string = "You are signed out or your session has expired. Please sign in again to continue."
56
+ internalErrorMessage string = "An internal error occurred. Please try again or contact the system administrator."
57
+ )
55
58
56
59
// ExtractAPIKey requires authentication using a valid API key.
57
60
// It handles extending an API key if it comes close to expiry,
@@ -126,8 +129,8 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
126
129
return
127
130
}
128
131
write (http .StatusInternalServerError , codersdk.Response {
129
- Message : "Internal error fetching API key by id." ,
130
- Detail : err .Error (),
132
+ Message : internalErrorMessage ,
133
+ Detail : fmt . Sprintf ( "Internal error fetching API key by id. %s" , err .Error () ),
131
134
})
132
135
return
133
136
}
@@ -154,7 +157,8 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
154
157
oauthConfig = oauth .Github
155
158
default :
156
159
write (http .StatusInternalServerError , codersdk.Response {
157
- Message : fmt .Sprintf ("Unexpected authentication type %q." , key .LoginType ),
160
+ Message : internalErrorMessage ,
161
+ Detail : fmt .Sprintf ("Unexpected authentication type %q." , key .LoginType ),
158
162
})
159
163
return
160
164
}
@@ -225,7 +229,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
225
229
})
226
230
if err != nil {
227
231
write (http .StatusInternalServerError , codersdk.Response {
228
- Message : signedOutErrorMessage ,
232
+ Message : internalErrorMessage ,
229
233
Detail : fmt .Sprintf ("API key couldn't update: %s." , err .Error ()),
230
234
})
231
235
return
@@ -238,8 +242,8 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
238
242
roles , err := db .GetAuthorizationUserRoles (r .Context (), key .UserID )
239
243
if err != nil {
240
244
write (http .StatusUnauthorized , codersdk.Response {
241
- Message : "Internal error fetching user's roles." ,
242
- Detail : err .Error (),
245
+ Message : internalErrorMessage ,
246
+ Detail : fmt . Sprintf ( "Internal error fetching user's roles. %s" , err .Error () ),
243
247
})
244
248
return
245
249
}
0 commit comments