Copilot commented on code in PR #9386:
URL: https://github.com/apache/devlake/pull/9386#discussion_r4550039120
##########
backend/plugins/azuredevops_go/api/remote_helper.go:
##########
@@ -260,7 +263,10 @@ func listRemoteRepos(
_ = g.Wait()
for _, v := range remoteRepos {
- pID := orgId + idSeparator + projectId
+ pID := projectId
+ if orgId != "" {
+ pID = orgId + idSeparator + projectId
+ }
Review Comment:
For on-prem connections, `orgId` may still be non-empty when parsing
previously-saved scope IDs (e.g., legacy `org||project` format). With this
logic, those on-prem scopes will continue producing org-prefixed parent IDs
instead of normalizing to project-only IDs, which can lead to inconsistent
IDs/duplicate trees. If the intent is to normalize on-prem IDs, gate the
org-prefixed branch on `connection.Endpoint == \"\"` (Cloud-only) or clear
`orgId` earlier for on-prem even when the incoming groupId contains an org
prefix.
##########
config-ui/src/plugins/register/azure/config.tsx:
##########
@@ -88,11 +88,28 @@ export const AzureGoConfig: IPluginConfig = {
initialValues: {},
fields: [
'name',
- ({ values, setValues }: any) => (
- <BaseURL key="base-url" value={values.endpoint} onChange={(val) =>
setValues({ endpoint: val })} />
+ ({
+ initialValues,
+ values,
+ setValues,
+ setErrors,
+ }: {
+ initialValues: { endpoint?: string };
+ values: { endpoint?: string };
+ setValues: (values: { endpoint: string }) => void;
+ setErrors: (errors: { endpoint: string }) => void;
+ }) => (
+ <BaseURL
+ key="base-url"
+ initialValue={initialValues.endpoint ?? ''}
+ value={values.endpoint}
+ onChange={(val) => setValues({ endpoint: val })}
+ setError={(error) => setErrors({ endpoint: error })}
Review Comment:
Passing `setError={(error) => setErrors({ endpoint: error })}` risks
clobbering errors from other fields because it replaces the entire errors
object with only `{ endpoint: ... }`. Prefer updating/merging the endpoint
error into existing errors (e.g., via a functional update or a field-scoped
setter) so other validation errors aren’t accidentally cleared.
##########
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:
This error drops the upstream response body, which often contains the
actionable reason (e.g., missing permissions, invalid provider, version
mismatch). Consider reading a bounded amount of the response body and including
it (or unmarshalled `message`) in the returned error so operators can diagnose
the failure without additional logging.
--
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]