Skip to content

Commit 4ff734f

Browse files
fix: where HTTP node URL, JSON text, and raw text template rendering could not find the corresponding rendering variables (coze-dev#745)
1 parent ff00dcb commit 4ff734f

File tree

5 files changed

+765
-33
lines changed

5 files changed

+765
-33
lines changed

backend/api/handler/coze/workflow_service_test.go

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4655,7 +4655,7 @@ func TestJsonSerializationDeserializationWithWarning(t *testing.T) {
46554655
})
46564656
}
46574657

4658-
func TestSetAppVariablesFOrSubProcesses(t *testing.T) {
4658+
func TestSetAppVariablesForSubProcesses(t *testing.T) {
46594659
mockey.PatchConvey("app variables for sub_process", t, func() {
46604660
r := newWfTestRunner(t)
46614661
defer r.closeFn()
@@ -4672,3 +4672,79 @@ func TestSetAppVariablesFOrSubProcesses(t *testing.T) {
46724672

46734673
})
46744674
}
4675+
4676+
func TestHttpImplicitDependencies(t *testing.T) {
4677+
mockey.PatchConvey("test http implicit dependencies", t, func() {
4678+
r := newWfTestRunner(t)
4679+
defer r.closeFn()
4680+
4681+
r.appVarS.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).Return("1.0", nil).AnyTimes()
4682+
4683+
idStr := r.load("httprequester/http_implicit_dependencies.json")
4684+
4685+
r.publish(idStr, "v0.0.1", true)
4686+
4687+
runner := mockcode.NewMockRunner(r.ctrl)
4688+
runner.EXPECT().Run(gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, request *coderunner.RunRequest) (*coderunner.RunResponse, error) {
4689+
in := request.Params["input"]
4690+
_ = in
4691+
result := make(map[string]any)
4692+
err := sonic.UnmarshalString(in.(string), &result)
4693+
if err != nil {
4694+
return nil, err
4695+
}
4696+
4697+
return &coderunner.RunResponse{
4698+
Result: result,
4699+
}, nil
4700+
}).AnyTimes()
4701+
4702+
code.SetCodeRunner(runner)
4703+
4704+
mockey.PatchConvey("test http node implicit dependencies", func() {
4705+
input := map[string]string{
4706+
"input": "a",
4707+
}
4708+
result, _ := r.openapiSyncRun(idStr, input)
4709+
4710+
batchRets := result["batch"].([]any)
4711+
loopRets := result["loop"].([]any)
4712+
4713+
for _, r := range batchRets {
4714+
assert.Contains(t, []any{
4715+
"http://echo.apifox.com/anything?aa=1.0&cc=1",
4716+
"http://echo.apifox.com/anything?aa=1.0&cc=2",
4717+
}, r)
4718+
}
4719+
for _, r := range loopRets {
4720+
assert.Contains(t, []any{
4721+
"http://echo.apifox.com/anything?a=1&m=123",
4722+
"http://echo.apifox.com/anything?a=2&m=123",
4723+
}, r)
4724+
}
4725+
4726+
})
4727+
4728+
mockey.PatchConvey("node debug http node implicit dependencies", func() {
4729+
exeID := r.nodeDebug(idStr, "109387",
4730+
withNDInput(map[string]string{
4731+
"__apiInfo_url_87fc7c69536cae843fa7f5113cf0067b": "m",
4732+
"__apiInfo_url_ac86361e3cd503952e71986dc091fa6f": "a",
4733+
"__body_bodyData_json_ac86361e3cd503952e71986dc091fa6f": "b",
4734+
"__body_bodyData_json_f77817a7cf8441279e1cfd8af4eeb1da": "1",
4735+
}))
4736+
4737+
e := r.getProcess(idStr, exeID, withSpecificNodeID("109387"))
4738+
e.assertSuccess()
4739+
4740+
ret := make(map[string]any)
4741+
err := sonic.UnmarshalString(e.output, &ret)
4742+
assert.Nil(t, err)
4743+
err = sonic.UnmarshalString(ret["body"].(string), &ret)
4744+
assert.Nil(t, err)
4745+
assert.Equal(t, ret["url"].(string), "http://echo.apifox.com/anything?a=a&m=m")
4746+
4747+
})
4748+
4749+
})
4750+
}

backend/domain/workflow/internal/canvas/convert/type_convert.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func CanvasBlockInputToTypeInfo(b *vo.BlockInput) (tInfo *vo.TypeInfo, err error
144144
}
145145
tInfo.Properties[subV.Name] = subTInfo
146146
} else if b.Value.Type == vo.BlockInputValueTypeObjectRef {
147-
subV, err := parseParam(subVAny)
147+
subV, err := ParseParam(subVAny)
148148
if err != nil {
149149
return nil, err
150150
}
@@ -195,7 +195,7 @@ func CanvasBlockInputToFieldInfo(b *vo.BlockInput, path einoCompose.FieldPath, p
195195

196196
for i := range paramList {
197197
paramAny := paramList[i]
198-
param, err := parseParam(paramAny)
198+
param, err := ParseParam(paramAny)
199199
if err != nil {
200200
return nil, err
201201
}
@@ -343,7 +343,7 @@ func parseBlockInputRef(content any) (*vo.BlockInputReference, error) {
343343
return p, nil
344344
}
345345

346-
func parseParam(v any) (*vo.Param, error) {
346+
func ParseParam(v any) (*vo.Param, error) {
347347
if pa, ok := v.(*vo.Param); ok {
348348
return pa, nil
349349
}
@@ -497,7 +497,7 @@ func SetOutputTypesForNodeSchema(n *vo.Node, ns *schema.NodeSchema) error {
497497

498498
func SetOutputsForNodeSchema(n *vo.Node, ns *schema.NodeSchema) error {
499499
for _, vAny := range n.Data.Outputs {
500-
param, err := parseParam(vAny)
500+
param, err := ParseParam(vAny)
501501
if err != nil {
502502
return err
503503
}
@@ -565,7 +565,7 @@ func BlockInputToNamedTypeInfo(name string, b *vo.BlockInput) (*vo.NamedTypeInfo
565565
}
566566
tInfo.Properties = append(tInfo.Properties, subNInfo)
567567
} else if b.Value.Type == vo.BlockInputValueTypeObjectRef {
568-
subV, err := parseParam(subVAny)
568+
subV, err := ParseParam(subVAny)
569569
if err != nil {
570570
return nil, err
571571
}

0 commit comments

Comments
 (0)