diff --git a/shortcuts/base/base_execute_test.go b/shortcuts/base/base_execute_test.go index 46ec996d..78bc1fab 100644 --- a/shortcuts/base/base_execute_test.go +++ b/shortcuts/base/base_execute_test.go @@ -907,6 +907,8 @@ func TestBaseFieldExecuteSearchOptions(t *testing.T) { } if got := stdout.String(); !strings.Contains(got, `"options"`) || !strings.Contains(got, `"已完成"`) { t.Fatalf("stdout=%s", got) + } else if strings.Contains(got, `"opt_1"`) { + t.Fatalf("stdout should not expose option ids: %s", got) } } diff --git a/shortcuts/base/field_ops.go b/shortcuts/base/field_ops.go index 0976c90d..dabd72f6 100644 --- a/shortcuts/base/field_ops.go +++ b/shortcuts/base/field_ops.go @@ -215,8 +215,31 @@ func executeFieldSearchOptions(runtime *common.RuntimeContext) error { "field_id": fieldRef, "field_name": fieldRef, "keyword": strings.TrimSpace(runtime.Str("keyword")), - "options": options, + "options": stripFieldOptionIDs(options), "total": total, }, nil) return nil } + +func stripFieldOptionIDs(options []interface{}) []interface{} { + if len(options) == 0 { + return options + } + normalized := make([]interface{}, 0, len(options)) + for _, option := range options { + record, ok := option.(map[string]interface{}) + if !ok { + normalized = append(normalized, option) + continue + } + copied := make(map[string]interface{}, len(record)) + for key, value := range record { + if key == "id" { + continue + } + copied[key] = value + } + normalized = append(normalized, copied) + } + return normalized +}