keremoge commented on code in PR #9386:
URL: https://github.com/apache/devlake/pull/9386#discussion_r4550397177
##########
backend/plugins/azuredevops_go/api/azuredevops/client.go:
##########
@@ -282,28 +286,36 @@ type GetRemoteRepositoriesArgs struct {
func (c *Client) GetRemoteRepositories(args GetRemoteRepositoriesArgs)
([]RemoteRepository, error) {
query := url.Values{}
query.Set("api-version", apiVersion)
+ query.Set("pageResults", "true")
if args.ServiceEndpoint != "" {
query.Set("serviceEndpointId", args.ServiceEndpoint)
}
var repos []RemoteRepository
- var response struct {
- Repository []RemoteRepository `json:"repositories"`
- }
-
for {
- path :=
fmt.Sprintf("%s/%s/_apis/sourceProviders/%s/repositories/", args.OrgId,
args.ProjectId, args.Provider)
+ var response struct {
+ Repository []RemoteRepository
`json:"repositories"`
+ ContinuationToken string
`json:"continuationToken"`
+ }
+ path :=
fmt.Sprintf("%s/_apis/sourceProviders/%s/repositories/",
c.projectPath(args.OrgId, args.ProjectId), url.PathEscape(args.Provider))
res, err := c.apiClient.Get(path, query, nil)
if err != nil {
return nil, errors.Internal.Wrap(err, "failed to read
remote repositories")
}
+ if res.StatusCode != http.StatusOK {
+ res.Body.Close()
+ return nil, errors.Internal.New(fmt.Sprintf("failed to
read remote repositories, upstream api call failed with (%v)", res.StatusCode))
Review Comment:
Fixed. Non-200 responses now include the HTTP status and up to 4 KiB of
upstream response detail. Body-read failures are also preserved. Added
regression coverage for JSON/plain-text errors, truncation, and interrupted
reads.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]