RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(go-models): harden ModelScope default transport handling (#15339)
glorydavid030237fc909acc996
diff --git a/internal/entity/models/modelscope.go b/internal/entity/models/modelscope.goindex 5dccc390de..9c937c027f 100644--- a/internal/entity/models/modelscope.go+++ b/internal/entity/models/modelscope.go@@ -72,7 +72,15 @@ type modelscopeModelListResponse struct {// NewModelScopeModel creates a new ModelScope model instance.func NewModelScopeModel(baseURL map[string]string, urlSuffix URLSuffix) *ModelScopeModel {- transport := http.DefaultTransport.(*http.Transport).Clone()+ defaultTransport, ok := http.DefaultTransport.(*http.Transport)+ var transport *http.Transport+ if ok {+ transport = defaultTransport.Clone()+ } else {+ transport = &http.Transport{+ Proxy: http.ProxyFromEnvironment,+ }+ }transport.MaxIdleConns = 100transport.MaxIdleConnsPerHost = 10transport.IdleConnTimeout = 90 * time.Seconddiff --git a/internal/entity/models/modelscope_test.go b/internal/entity/models/modelscope_test.goindex 5a698f569a..409d03bad3 100644--- a/internal/entity/models/modelscope_test.go+++ b/internal/entity/models/modelscope_test.go@@ -26,6 +26,12 @@ import ("time")+type roundTripperFunc func(*http.Request) (*http.Response, error)++func (f roundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) {+ return f(r)+}+func newModelScopeForTest(baseURL string) *ModelScopeModel {return NewModelScopeModel(map[string]string{"default": baseURL},@@ -79,6 +85,20 @@ func TestModelScopeFactoryRoute(t *testing.T) {}}+func TestModelScopeNewModelWithCustomDefaultTransport(t *testing.T) {+ original := http.DefaultTransport+ http.DefaultTransport = roundTripperFunc(func(*http.Request) (*http.Response, error) {+ return nil, nil+ })+ t.Cleanup(func() {+ http.DefaultTransport = original+ })++ if model := NewModelScopeModel(map[string]string{"default": "http://unused"}, URLSuffix{}); model == nil {+ t.Fatal("NewModelScopeModel returned nil")+ }+}+func TestModelScopeChatHappyPathNormalizesBaseURLAndOmitsEmptyAuth(t *testing.T) {var seen map[string]interface{}srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {