@@ -936,7 +936,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
936
936
gitURL := r .URL .Query ().Get ("url" )
937
937
if gitURL == "" {
938
938
httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
939
- Message : "Missing url query parameter!" ,
939
+ Message : "Missing ' url' query parameter!" ,
940
940
})
941
941
return
942
942
}
@@ -962,23 +962,23 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
962
962
// We must get the workspace to get the owner ID!
963
963
resource , err := api .Database .GetWorkspaceResourceByID (ctx , workspaceAgent .ResourceID )
964
964
if err != nil {
965
- httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
965
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
966
966
Message : "Failed to get workspace resource." ,
967
967
Detail : err .Error (),
968
968
})
969
969
return
970
970
}
971
971
build , err := api .Database .GetWorkspaceBuildByJobID (ctx , resource .JobID )
972
972
if err != nil {
973
- httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
973
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
974
974
Message : "Failed to get build." ,
975
975
Detail : err .Error (),
976
976
})
977
977
return
978
978
}
979
979
workspace , err := api .Database .GetWorkspaceByID (ctx , build .WorkspaceID )
980
980
if err != nil {
981
- httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
981
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
982
982
Message : "Failed to get workspace." ,
983
983
Detail : err .Error (),
984
984
})
@@ -1013,6 +1013,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
1013
1013
}
1014
1014
defer cancelFunc ()
1015
1015
ticker := time .NewTicker (time .Second )
1016
+ defer ticker .Stop ()
1016
1017
for {
1017
1018
select {
1018
1019
case <- r .Context ().Done ():
@@ -1025,7 +1026,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
1025
1026
UserID : workspace .OwnerID ,
1026
1027
})
1027
1028
if err != nil {
1028
- httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
1029
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
1029
1030
Message : "Failed to get git auth link." ,
1030
1031
Detail : err .Error (),
1031
1032
})
@@ -1042,7 +1043,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
1042
1043
// This is the URL that will redirect the user with a state token.
1043
1044
redirectURL , err := api .AccessURL .Parse (fmt .Sprintf ("/gitauth/%s" , gitAuthConfig .ID ))
1044
1045
if err != nil {
1045
- httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
1046
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
1046
1047
Message : "Failed to parse access URL." ,
1047
1048
Detail : err .Error (),
1048
1049
})
@@ -1055,7 +1056,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
1055
1056
})
1056
1057
if err != nil {
1057
1058
if ! errors .Is (err , sql .ErrNoRows ) {
1058
- httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
1059
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
1059
1060
Message : "Failed to get git auth link." ,
1060
1061
Detail : err .Error (),
1061
1062
})
@@ -1091,7 +1092,7 @@ func (api *API) workspaceAgentsGitAuth(rw http.ResponseWriter, r *http.Request)
1091
1092
OAuthExpiry : token .Expiry ,
1092
1093
})
1093
1094
if err != nil {
1094
- httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
1095
+ httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
1095
1096
Message : "Failed to update git auth link." ,
1096
1097
Detail : err .Error (),
1097
1098
})
0 commit comments