Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions shortcuts/base/base_execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
25 changes: 24 additions & 1 deletion shortcuts/base/field_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading