@@ -1160,7 +1160,14 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
1160
1160
continue
1161
1161
}
1162
1162
if gitAuthConfig .ValidateURL != "" {
1163
- valid , _ := validateGitToken (ctx , gitAuthConfig .ValidateURL , gitAuthLink .OAuthAccessToken )
1163
+ valid , err := validateGitToken (ctx , gitAuthConfig .ValidateURL , gitAuthLink .OAuthAccessToken )
1164
+ if err != nil {
1165
+ api .Logger .Warn (ctx , "failed to validate git auth token" ,
1166
+ slog .F ("workspace_owner_id" , workspace .OwnerID .String ()),
1167
+ slog .F ("validate_url" , gitAuthConfig .ValidateURL ),
1168
+ slog .Error (err ),
1169
+ )
1170
+ }
1164
1171
if ! valid {
1165
1172
continue
1166
1173
}
@@ -1221,9 +1228,9 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
1221
1228
}
1222
1229
1223
1230
if gitAuthConfig .ValidateURL != "" {
1224
- valid , err := validateGitToken (r . Context () , gitAuthConfig .ValidateURL , token .AccessToken )
1231
+ valid , err := validateGitToken (ctx , gitAuthConfig .ValidateURL , token .AccessToken )
1225
1232
if err != nil {
1226
- httpapi .Write (r . Context () , rw , http .StatusInternalServerError , codersdk.Response {
1233
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
1227
1234
Message : "Failed to validate Git authentication token." ,
1228
1235
Detail : err .Error (),
1229
1236
})
@@ -1278,7 +1285,7 @@ func validateGitToken(ctx context.Context, validateURL, token string) (bool, err
1278
1285
}
1279
1286
if res .StatusCode != http .StatusOK {
1280
1287
data , _ := io .ReadAll (res .Body )
1281
- return false , xerrors .Errorf ("body: %s" , data )
1288
+ return false , xerrors .Errorf ("git token validation failed: status %d: body: %s" , res . StatusCode , data )
1282
1289
}
1283
1290
return true , nil
1284
1291
}
0 commit comments