fix(plugin): update tool may reset request or response parameters (#302)
This commit is contained in:
@@ -853,3 +853,11 @@ func (p *pluginRepoImpl) MoveAPPPluginToLibrary(ctx context.Context, draftPlugin
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *pluginRepoImpl) UpdateDebugExample(ctx context.Context, pluginID int64, openapiDoc *model.Openapi3T) (err error) {
|
||||
updatedPlugin := entity.NewPluginInfo(&model.PluginInfo{
|
||||
ID: pluginID,
|
||||
OpenapiDoc: openapiDoc,
|
||||
})
|
||||
return p.pluginDraftDAO.Update(ctx, updatedPlugin)
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ type PluginRepository interface {
|
||||
UpdateDraftPluginWithCode(ctx context.Context, req *UpdatePluginDraftWithCode) (err error)
|
||||
DeleteDraftPlugin(ctx context.Context, pluginID int64) (err error)
|
||||
DeleteAPPAllPlugins(ctx context.Context, appID int64) (pluginIDs []int64, err error)
|
||||
UpdateDebugExample(ctx context.Context, pluginID int64, openapiDoc *plugin.Openapi3T) (err error)
|
||||
|
||||
GetOnlinePlugin(ctx context.Context, pluginID int64, opts ...PluginSelectedOptions) (plugin *entity.PluginInfo, exist bool, err error)
|
||||
MGetOnlinePlugins(ctx context.Context, pluginIDs []int64, opts ...PluginSelectedOptions) (plugins []*entity.PluginInfo, err error)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
pluginConf "github.com/coze-dev/coze-studio/backend/domain/plugin/conf"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal"
|
||||
@@ -389,41 +388,3 @@ func (t *toolRepoImpl) MGetVersionAgentTool(ctx context.Context, agentID int64,
|
||||
func (t *toolRepoImpl) BatchCreateVersionAgentTools(ctx context.Context, agentID int64, agentVersion string, tools []*entity.ToolInfo) (err error) {
|
||||
return t.agentToolVersionDAO.BatchCreate(ctx, agentID, agentVersion, tools)
|
||||
}
|
||||
|
||||
func (t *toolRepoImpl) UpdateDraftToolAndDebugExample(ctx context.Context, pluginID int64, doc *plugin.Openapi3T, updatedTool *entity.ToolInfo) (err error) {
|
||||
tx := t.query.Begin()
|
||||
if tx.Error != nil {
|
||||
return tx.Error
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if e := tx.Rollback(); e != nil {
|
||||
logs.CtxErrorf(ctx, "rollback failed, err=%v", e)
|
||||
}
|
||||
err = fmt.Errorf("catch panic: %v\nstack=%s", r, string(debug.Stack()))
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
if e := tx.Rollback(); e != nil {
|
||||
logs.CtxErrorf(ctx, "rollback failed, err=%v", e)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
err = t.toolDraftDAO.UpdateWithTX(ctx, tx, updatedTool)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
updatedPlugin := entity.NewPluginInfo(&plugin.PluginInfo{
|
||||
ID: pluginID,
|
||||
OpenapiDoc: doc,
|
||||
})
|
||||
err = t.pluginDraftDAO.UpdateWithTX(ctx, tx, updatedPlugin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package repository
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
)
|
||||
|
||||
@@ -54,8 +53,6 @@ type ToolRepository interface {
|
||||
MGetVersionAgentTool(ctx context.Context, agentID int64, vAgentTools []entity.VersionAgentTool) (tools []*entity.ToolInfo, err error)
|
||||
BatchCreateVersionAgentTools(ctx context.Context, agentID int64, agentVersion string, tools []*entity.ToolInfo) (err error)
|
||||
|
||||
UpdateDraftToolAndDebugExample(ctx context.Context, pluginID int64, doc *plugin.Openapi3T, updatedTool *entity.ToolInfo) (err error)
|
||||
|
||||
GetPluginAllDraftTools(ctx context.Context, pluginID int64, opts ...ToolSelectedOptions) (tools []*entity.ToolInfo, err error)
|
||||
GetPluginAllOnlineTools(ctx context.Context, pluginID int64) (tools []*entity.ToolInfo, err error)
|
||||
ListPluginDraftTools(ctx context.Context, pluginID int64, pageInfo entity.PageInfo) (tools []*entity.ToolInfo, total int64, err error)
|
||||
|
||||
Reference in New Issue
Block a user