Copilot commented on code in PR #8935:
URL: https://github.com/apache/devlake/pull/8935#discussion_r3498522086


##########
backend/plugins/gh-copilot/service/api_path_test.go:
##########
@@ -0,0 +1,30 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package service
+
+import (
+       "testing"
+
+       "github.com/stretchr/testify/assert"
+)
+
+func TestCopilotAPIPathPreservesHyphenatedEnterpriseSlug(t *testing.T) {
+       path := copilotAPIPath("enterprises", "my-enterprise", 
"copilot/billing/seats")
+
+       assert.Equal(t, "enterprises/my-enterprise/copilot/billing/seats", path)
+}

Review Comment:
   The helper trims whitespace and path-escapes the slug and also trims a 
leading "/" from resource, but the test only covers hyphen preservation. Adding 
assertions for these behaviors will better lock in the contract described in 
the PR.



##########
backend/plugins/gh-copilot/tasks/api_path_test.go:
##########
@@ -0,0 +1,30 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package tasks
+
+import (
+       "testing"
+
+       "github.com/stretchr/testify/require"
+)
+
+func TestCopilotAPIPathPreservesHyphenatedEnterpriseSlug(t *testing.T) {
+       path := copilotAPIPath("enterprises", "my-enterprise", 
"copilot/billing/seats")
+
+       require.Equal(t, "enterprises/my-enterprise/copilot/billing/seats", 
path)
+}

Review Comment:
   The helper trims whitespace and path-escapes the slug and also trims a 
leading "/" from resource, but the test only covers hyphen preservation. Adding 
assertions for these behaviors will better lock in the contract described in 
the PR.



##########
docker-compose-dev-postgresql.yml:
##########
@@ -16,7 +16,7 @@
 name: devlake-postgresql
 
 services:
-  postgres:
+  postgres: 

Review Comment:
   Remove trailing whitespace after the service key; it’s noise in diffs and 
can trip whitespace-sensitive tooling.



##########
backend/plugins/gh-copilot/tasks/api_path.go:
##########
@@ -0,0 +1,28 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package tasks
+
+import (
+       "fmt"
+       "net/url"
+       "strings"
+)
+
+func copilotAPIPath(namespace, slug, resource string) string {
+       return fmt.Sprintf("%s/%s/%s", namespace, 
url.PathEscape(strings.TrimSpace(slug)), strings.TrimPrefix(resource, "/"))
+}

Review Comment:
   This helper is duplicated verbatim in both `tasks` and `service` packages. 
To avoid future drift (e.g., one side changing escaping rules), consider moving 
it to a shared package under `backend/plugins/gh-copilot/` (e.g., 
`internal/utils`) and reusing it from both call sites.



##########
config-ui/src/plugins/components/connection-form/index.tsx:
##########
@@ -59,6 +59,7 @@ const buildUpdateTestPayload = (connection: any, values: any, 
customHeaders: ICu
   dbUrl: isEqual(connection?.dbUrl, values.dbUrl) ? undefined : values.dbUrl,
   companyId: isEqual(connection?.companyId, values.companyId) ? undefined : 
values.companyId,
   organization: isEqual(connection?.organization, values.organization) ? 
undefined : values.organization,
+  enterprise: isEqual(connection?.enterprise, values.enterprise) ? undefined : 
values.enterprise,
   customHeaders: isEqual(connection?.customHeaders, customHeaders) ? undefined 
: customHeaders,

Review Comment:
   `enterprise` is now included in the connection test payload, but the API 
typings for `API.connection.test`/`testOld` currently don’t include 
`enterprise` in their allowed payload keys. Updating the type definitions would 
keep the frontend type-safe and prevent future callers from being blocked by 
overly narrow types.



##########
backend/plugins/gh-copilot/service/api_path.go:
##########
@@ -0,0 +1,28 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package service
+
+import (
+       "fmt"
+       "net/url"
+       "strings"
+)
+
+func copilotAPIPath(namespace, slug, resource string) string {
+       return fmt.Sprintf("%s/%s/%s", namespace, 
url.PathEscape(strings.TrimSpace(slug)), strings.TrimPrefix(resource, "/"))
+}

Review Comment:
   This helper is duplicated verbatim in both `service` and `tasks` packages. 
To avoid future drift (e.g., one side changing escaping rules), consider moving 
it to a shared package under `backend/plugins/gh-copilot/` (e.g., 
`internal/utils`) and reusing it from both call sites.



-- 
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]

Reply via email to