This is an automated email from the ASF dual-hosted git repository.

ewega pushed a commit to branch fix/#8860
in repository https://gitbox.apache.org/repos/asf/devlake.git


The following commit(s) were added to refs/heads/fix/#8860 by this push:
     new 1ceed408b fix(gh-copilot): address review feedback
1ceed408b is described below

commit 1ceed408b0999ecd7cd3b88da8ee8b98f21df7b2
Author: ewega <[email protected]>
AuthorDate: Mon Jul 13 16:07:30 2026 +0200

    fix(gh-copilot): address review feedback
    
    Co-authored-by: Copilot App <[email protected]>
    
    Copilot-Session: 0d5d6ca1-d263-4779-8fb9-a34ccdaaaadf
---
 .../plugins/gh-copilot/{tasks => internal/utils}/api_path.go |  4 ++--
 .../gh-copilot/{tasks => internal/utils}/api_path_test.go    | 12 +++++++++---
 backend/plugins/gh-copilot/service/api_path.go               |  8 ++------
 backend/plugins/gh-copilot/service/api_path_test.go          | 12 ++++++++++++
 backend/plugins/gh-copilot/tasks/api_path.go                 |  8 ++------
 backend/plugins/gh-copilot/tasks/api_path_test.go            | 12 ++++++++++++
 config-ui/src/api/connection/index.ts                        |  2 ++
 config-ui/src/types/connection.ts                            |  2 ++
 docker-compose-dev-postgresql.yml                            |  2 +-
 9 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/backend/plugins/gh-copilot/tasks/api_path.go 
b/backend/plugins/gh-copilot/internal/utils/api_path.go
similarity index 92%
copy from backend/plugins/gh-copilot/tasks/api_path.go
copy to backend/plugins/gh-copilot/internal/utils/api_path.go
index 0d177ee14..f9837eefd 100644
--- a/backend/plugins/gh-copilot/tasks/api_path.go
+++ b/backend/plugins/gh-copilot/internal/utils/api_path.go
@@ -15,7 +15,7 @@ See the License for the specific language governing 
permissions and
 limitations under the License.
 */
 
-package tasks
+package utils
 
 import (
        "fmt"
@@ -23,6 +23,6 @@ import (
        "strings"
 )
 
-func copilotAPIPath(namespace, slug, resource string) string {
+func CopilotAPIPath(namespace, slug, resource string) string {
        return fmt.Sprintf("%s/%s/%s", namespace, 
url.PathEscape(strings.TrimSpace(slug)), strings.TrimPrefix(resource, "/"))
 }
diff --git a/backend/plugins/gh-copilot/tasks/api_path_test.go 
b/backend/plugins/gh-copilot/internal/utils/api_path_test.go
similarity index 71%
copy from backend/plugins/gh-copilot/tasks/api_path_test.go
copy to backend/plugins/gh-copilot/internal/utils/api_path_test.go
index b92420484..72cb6e8d0 100644
--- a/backend/plugins/gh-copilot/tasks/api_path_test.go
+++ b/backend/plugins/gh-copilot/internal/utils/api_path_test.go
@@ -15,7 +15,7 @@ See the License for the specific language governing 
permissions and
 limitations under the License.
 */
 
-package tasks
+package utils
 
 import (
        "testing"
@@ -23,8 +23,14 @@ import (
        "github.com/stretchr/testify/require"
 )
 
-func TestCopilotAPIPathPreservesHyphenatedEnterpriseSlug(t *testing.T) {
-       path := copilotAPIPath("enterprises", "my-enterprise", 
"copilot/billing/seats")
+func TestCopilotAPIPathTrimsAndEscapesSlugAndResource(t *testing.T) {
+       path := CopilotAPIPath("enterprises", "  my-enterprise  ", 
"/copilot/billing/seats")
 
        require.Equal(t, "enterprises/my-enterprise/copilot/billing/seats", 
path)
 }
+
+func TestCopilotAPIPathEscapesSlugSegments(t *testing.T) {
+       path := CopilotAPIPath("orgs", "my enterprise", "/copilot/billing")
+
+       require.Equal(t, "orgs/my%20enterprise/copilot/billing", path)
+}
diff --git a/backend/plugins/gh-copilot/service/api_path.go 
b/backend/plugins/gh-copilot/service/api_path.go
index ec593c946..a07c926c4 100644
--- a/backend/plugins/gh-copilot/service/api_path.go
+++ b/backend/plugins/gh-copilot/service/api_path.go
@@ -17,12 +17,8 @@ limitations under the License.
 
 package service
 
-import (
-       "fmt"
-       "net/url"
-       "strings"
-)
+import "github.com/apache/incubator-devlake/plugins/gh-copilot/internal/utils"
 
 func copilotAPIPath(namespace, slug, resource string) string {
-       return fmt.Sprintf("%s/%s/%s", namespace, 
url.PathEscape(strings.TrimSpace(slug)), strings.TrimPrefix(resource, "/"))
+       return utils.CopilotAPIPath(namespace, slug, resource)
 }
diff --git a/backend/plugins/gh-copilot/service/api_path_test.go 
b/backend/plugins/gh-copilot/service/api_path_test.go
index 4a57cc1e4..84a53dfba 100644
--- a/backend/plugins/gh-copilot/service/api_path_test.go
+++ b/backend/plugins/gh-copilot/service/api_path_test.go
@@ -28,3 +28,15 @@ func TestCopilotAPIPathPreservesHyphenatedEnterpriseSlug(t 
*testing.T) {
 
        assert.Equal(t, "enterprises/my-enterprise/copilot/billing/seats", path)
 }
+
+func TestCopilotAPIPathTrimsAndEscapesSlugAndResource(t *testing.T) {
+       path := copilotAPIPath("enterprises", "  my-enterprise  ", 
"/copilot/billing/seats")
+
+       assert.Equal(t, "enterprises/my-enterprise/copilot/billing/seats", path)
+}
+
+func TestCopilotAPIPathEscapesSlugSegments(t *testing.T) {
+       path := copilotAPIPath("orgs", "my enterprise", "/copilot/billing")
+
+       assert.Equal(t, "orgs/my%20enterprise/copilot/billing", path)
+}
diff --git a/backend/plugins/gh-copilot/tasks/api_path.go 
b/backend/plugins/gh-copilot/tasks/api_path.go
index 0d177ee14..d8b73295b 100644
--- a/backend/plugins/gh-copilot/tasks/api_path.go
+++ b/backend/plugins/gh-copilot/tasks/api_path.go
@@ -17,12 +17,8 @@ limitations under the License.
 
 package tasks
 
-import (
-       "fmt"
-       "net/url"
-       "strings"
-)
+import "github.com/apache/incubator-devlake/plugins/gh-copilot/internal/utils"
 
 func copilotAPIPath(namespace, slug, resource string) string {
-       return fmt.Sprintf("%s/%s/%s", namespace, 
url.PathEscape(strings.TrimSpace(slug)), strings.TrimPrefix(resource, "/"))
+       return utils.CopilotAPIPath(namespace, slug, resource)
 }
diff --git a/backend/plugins/gh-copilot/tasks/api_path_test.go 
b/backend/plugins/gh-copilot/tasks/api_path_test.go
index b92420484..b19e0bee3 100644
--- a/backend/plugins/gh-copilot/tasks/api_path_test.go
+++ b/backend/plugins/gh-copilot/tasks/api_path_test.go
@@ -28,3 +28,15 @@ func TestCopilotAPIPathPreservesHyphenatedEnterpriseSlug(t 
*testing.T) {
 
        require.Equal(t, "enterprises/my-enterprise/copilot/billing/seats", 
path)
 }
+
+func TestCopilotAPIPathTrimsAndEscapesSlugAndResource(t *testing.T) {
+       path := copilotAPIPath("enterprises", "  my-enterprise  ", 
"/copilot/billing/seats")
+
+       require.Equal(t, "enterprises/my-enterprise/copilot/billing/seats", 
path)
+}
+
+func TestCopilotAPIPathEscapesSlugSegments(t *testing.T) {
+       path := copilotAPIPath("orgs", "my enterprise", "/copilot/billing")
+
+       require.Equal(t, "orgs/my%20enterprise/copilot/billing", path)
+}
diff --git a/config-ui/src/api/connection/index.ts 
b/config-ui/src/api/connection/index.ts
index 2728b103e..a09e6450b 100644
--- a/config-ui/src/api/connection/index.ts
+++ b/config-ui/src/api/connection/index.ts
@@ -56,6 +56,7 @@ export const test = (
       | 'adminApiKey'
       | 'organization'
       | 'organizationId'
+      | 'enterprise'
       | 'customHeaders'
     >
   >,
@@ -79,6 +80,7 @@ export const testOld = (
     | 'adminApiKey'
     | 'organization'
     | 'organizationId'
+    | 'enterprise'
     | 'customHeaders'
   >,
 ): Promise<IConnectionOldTestResult> => request(`/plugins/${plugin}/test`, { 
method: 'post', data: payload });
diff --git a/config-ui/src/types/connection.ts 
b/config-ui/src/types/connection.ts
index 17a3b85af..df04a45b5 100644
--- a/config-ui/src/types/connection.ts
+++ b/config-ui/src/types/connection.ts
@@ -38,6 +38,7 @@ export interface IConnectionAPI {
   rateLimitPerHour?: number;
   organization?: string;
   organizationId?: string;
+  enterprise?: string;
   customHeaders?: ICustomHeader[];
 }
 
@@ -95,5 +96,6 @@ export interface IConnection {
   rateLimitPerHour?: number;
   organization?: string;
   organizationId?: string;
+  enterprise?: string;
   customHeaders?: ICustomHeader[];
 }
diff --git a/docker-compose-dev-postgresql.yml 
b/docker-compose-dev-postgresql.yml
index b718cf5d3..eff854777 100644
--- a/docker-compose-dev-postgresql.yml
+++ b/docker-compose-dev-postgresql.yml
@@ -16,7 +16,7 @@
 name: devlake-postgresql
 
 services:
-  postgres: 
+  postgres:
     image: postgres:17.2
     volumes:
       - postgres-storage:/var/lib/postgresql

Reply via email to