diff --git a/shortcuts/sheets/execute_paths_test.go b/shortcuts/sheets/execute_paths_test.go index c84d994c0..17b61f463 100644 --- a/shortcuts/sheets/execute_paths_test.go +++ b/shortcuts/sheets/execute_paths_test.go @@ -93,6 +93,36 @@ func TestExecute_WikiURLResolvesToSheet(t *testing.T) { } } +// TestExecute_RevisionGet_WikiURL guards RevisionGet's custom Execute hook: +// the wiki node token must be resolved before get_workbook_structure runs. +func TestExecute_RevisionGet_WikiURL(t *testing.T) { + t.Parallel() + getNode := &httpmock.Stub{ + Method: "GET", + URL: "/open-apis/wiki/v2/spaces/get_node", + Body: map[string]interface{}{ + "code": 0, + "msg": "success", + "data": map[string]interface{}{ + "node": map[string]interface{}{ + "obj_type": "sheet", + "obj_token": testToken, + }, + }, + }, + } + tool := toolOutputStub(testToken, "read", `{"revision":60}`) + out, err := runShortcutWithStubs(t, RevisionGet, + []string{"--url", "https://example.feishu.cn/wiki/wikTestNODE"}, getNode, tool) + if err != nil { + t.Fatalf("execute failed: %v\nout=%s", err, out) + } + data := decodeEnvelopeData(t, out) + if data["revision"] != float64(60) { + t.Fatalf("revision = %v, want 60; out=%s", data["revision"], out) + } +} + // TestExecute_WikiURLWrongObjType rejects a wiki node that resolves to a // non-spreadsheet obj_type before any tool invoke. func TestExecute_WikiURLWrongObjType(t *testing.T) { diff --git a/shortcuts/sheets/lark_sheet_revision_get.go b/shortcuts/sheets/lark_sheet_revision_get.go index 4ca8abc34..102f0dd97 100644 --- a/shortcuts/sheets/lark_sheet_revision_get.go +++ b/shortcuts/sheets/lark_sheet_revision_get.go @@ -42,7 +42,7 @@ var RevisionGet = common.Shortcut{ }) }, Execute: func(ctx context.Context, runtime *common.RuntimeContext) error { - token, err := resolveSpreadsheetToken(runtime) + token, err := resolveSpreadsheetTokenExec(runtime) if err != nil { return err }