From d80f8ecebdede7b7b64ca8f59f06ad15d6b049ce Mon Sep 17 00:00:00 2001 From: Ryo Date: Wed, 22 Oct 2025 11:43:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20sync=20legacy=20model=20EnableBase64Url?= =?UTF-8?q?=20config=20and=20handle=20not=20found=20er=E2=80=A6=20(#2366)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/modelmgr/deprecate_model_get.go | 5 +++++ .../domain/agent/singleagent/service/publish.go | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/backend/bizpkg/config/modelmgr/deprecate_model_get.go b/backend/bizpkg/config/modelmgr/deprecate_model_get.go index 1a092a168..1037edda7 100644 --- a/backend/bizpkg/config/modelmgr/deprecate_model_get.go +++ b/backend/bizpkg/config/modelmgr/deprecate_model_get.go @@ -282,6 +282,10 @@ func toNewModel(old *OldModel) (*Model, error) { m.Connection.Claude = modelMeta.Connection.Claude } + if old.Meta.ConnConfig.EnableBase64Url != nil { + m.EnableBase64URL = *old.Meta.ConnConfig.EnableBase64Url + } + logs.Debugf("to new model, old: %v \n new %v", conv.DebugJsonToStr(old), conv.DebugJsonToStr(m)) @@ -360,6 +364,7 @@ type OldConfig struct { TopK *int `json:"top_k,omitempty" yaml:"top_k"` Stop []string `json:"stop,omitempty" yaml:"stop"` EnableThinking *bool `json:"enable_thinking,omitempty" yaml:"enable_thinking,omitempty"` + EnableBase64Url *bool `json:"enable_base64_url,omitempty" yaml:"enable_base64_url,omitempty"` OpenAI *OpenAIConfig `json:"open_ai,omitempty" yaml:"openai"` Claude *ClaudeConfig `json:"claude,omitempty" yaml:"claude"` diff --git a/backend/domain/agent/singleagent/service/publish.go b/backend/domain/agent/singleagent/service/publish.go index e4c279c79..6ae1aa2cf 100644 --- a/backend/domain/agent/singleagent/service/publish.go +++ b/backend/domain/agent/singleagent/service/publish.go @@ -18,12 +18,14 @@ package singleagent import ( "context" + "errors" "sort" "time" "github.com/coze-dev/coze-studio/backend/api/model/app/developer_api" crossconnector "github.com/coze-dev/coze-studio/backend/crossdomain/contract/connector" "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity" + "github.com/coze-dev/coze-studio/backend/pkg/kvstore" "github.com/coze-dev/coze-studio/backend/pkg/lang/conv" "github.com/coze-dev/coze-studio/backend/pkg/logs" "github.com/coze-dev/coze-studio/backend/types/consts" @@ -44,7 +46,7 @@ func (s *singleAgentImpl) SavePublishRecord(ctx context.Context, p *entity.Singl } func (s *singleAgentImpl) GetPublishedTime(ctx context.Context, agentID int64) (int64, error) { - pubInfo, err := s.PublishInfoRepo.Get(ctx, consts.PublishInfoKeyPrefix, conv.Int64ToStr(agentID)) + pubInfo, err := s.GetPublishedInfo(ctx, agentID) if err != nil { return 0, err } @@ -54,7 +56,7 @@ func (s *singleAgentImpl) GetPublishedTime(ctx context.Context, agentID int64) ( func (s *singleAgentImpl) UpdatePublishInfo(ctx context.Context, agentID int64, connectorIDs []int64) error { now := time.Now().UnixMilli() - pubInfo, err := s.PublishInfoRepo.Get(ctx, consts.PublishInfoKeyPrefix, conv.Int64ToStr(agentID)) + pubInfo, err := s.GetPublishedInfo(ctx, agentID) if err != nil { return err } @@ -83,7 +85,15 @@ func (s *singleAgentImpl) UpdatePublishInfo(ctx context.Context, agentID int64, } func (s *singleAgentImpl) GetPublishedInfo(ctx context.Context, agentID int64) (*entity.PublishInfo, error) { - return s.PublishInfoRepo.Get(ctx, consts.PublishInfoKeyPrefix, conv.Int64ToStr(agentID)) + pubInfo, err := s.PublishInfoRepo.Get(ctx, consts.PublishInfoKeyPrefix, conv.Int64ToStr(agentID)) + if err != nil { + if errors.Is(err, kvstore.ErrKeyNotFound) { + return &entity.PublishInfo{}, nil + } + return nil, err + } + + return pubInfo, nil } func (s *singleAgentImpl) GetPublishConnectorList(ctx context.Context, agentID int64) (*entity.PublishConnectorData, error) {