fix: ListScopes must not return null (#5356)
The ListScopes endpoint was responsing with a "null" body instead of "[]" when there was no scope.
Co-authored-by: Camille Teruel <camille.teruel@meri.co>
diff --git a/backend/plugins/github/models/migrationscripts/register.go b/backend/plugins/github/models/migrationscripts/register.go
index 518f347..676471c 100644
--- a/backend/plugins/github/models/migrationscripts/register.go
+++ b/backend/plugins/github/models/migrationscripts/register.go
@@ -23,7 +23,6 @@
// All return all the migration scripts
func All() []plugin.MigrationScript {
- println("github register.go")
return []plugin.MigrationScript{
new(addInitTables),
new(addGithubRunsTable),
diff --git a/backend/python/test/fakeplugin/fakeplugin/main.py b/backend/python/test/fakeplugin/fakeplugin/main.py
index 55c5489..213641b 100644
--- a/backend/python/test/fakeplugin/fakeplugin/main.py
+++ b/backend/python/test/fakeplugin/fakeplugin/main.py
@@ -18,10 +18,9 @@
from typing import Optional
import json
-from sqlmodel import Field
from pydantic import SecretStr
-from pydevlake import Plugin, Connection, TransformationRule, Stream, ToolModel, ToolScope, RemoteScopeGroup, DomainType
+from pydevlake import Plugin, Connection, TransformationRule, Stream, ToolModel, ToolScope, RemoteScopeGroup, DomainType, Field
from pydevlake.domain_layer.devops import CicdScope, CICDPipeline, CICDStatus, CICDResult, CICDType
VALID_TOKEN = "this_is_a_valid_token"
diff --git a/backend/server/services/remote/plugin/scope_api.go b/backend/server/services/remote/plugin/scope_api.go
index 0d1839f..bc768fa 100644
--- a/backend/server/services/remote/plugin/scope_api.go
+++ b/backend/server/services/remote/plugin/scope_api.go
@@ -18,9 +18,10 @@
package plugin
import (
+ "net/http"
+
"github.com/apache/incubator-devlake/server/services/remote/models"
"github.com/mitchellh/mapstructure"
- "net/http"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
@@ -103,8 +104,8 @@
// convertScopeResponse adapt the "remote" scopes to a serializable api.ScopeRes
func convertScopeResponse(scopes ...*api.ScopeRes[models.RemoteScope]) ([]map[string]any, errors.Error) {
- var responses []map[string]any
- for _, scope := range scopes {
+ responses := make([]map[string]any, len(scopes))
+ for i, scope := range scopes {
resMap := map[string]any{}
err := models.MapTo(api.ScopeRes[map[string]any]{
Scope: nil, //ignore intentionally
@@ -123,7 +124,7 @@
for k, v := range scopeMap {
resMap[k] = v
}
- responses = append(responses, resMap)
+ responses[i] = resMap
}
return responses, nil
}