Skip to content

feat: add task +get shortcut for single task detail retrieval#940

Closed
Zhang-986 wants to merge 1 commit into
larksuite:mainfrom
Zhang-986:feat/task-get-shortcut
Closed

feat: add task +get shortcut for single task detail retrieval#940
Zhang-986 wants to merge 1 commit into
larksuite:mainfrom
Zhang-986:feat/task-get-shortcut

Conversation

@Zhang-986
Copy link
Copy Markdown
Contributor

@Zhang-986 Zhang-986 commented May 18, 2026

Summary

task 模块有 create、update、complete、search 这些命令,但唯独没有按 ID 查单个任务详情的功能。getTaskDetail 这个 helper 其实已经在 +complete+search 里用了,只是没暴露成独立命令。这个 PR 就是把它补上。

The task module has shortcuts for creating, updating, completing, and searching tasks, but no way to fetch a single task by ID. The getTaskDetail helper already exists internally (used by +complete and +search), so this PR just exposes it as a standalone task +get command.

Changes

  • 新增 task +get 命令,支持 --task-id(GUID 或 applink URL)、--format--jq--dry-run

  • Shortcuts() 里注册 GetTask

  • 补了单元测试(pretty/json 输出)和 dry-run E2E 测试(GUID 输入 + applink URL 解析)

  • Added task +get shortcut with --task-id (GUID or applink URL), --format, --jq, --dry-run

  • Registered GetTask in Shortcuts()

  • Added unit tests (pretty/json output) and dry-run E2E test (GUID input + applink URL resolution)

Test Plan

  • go test ./shortcuts/task/... -race 通过

  • go vet / gofmt / go mod tidy / golangci-lint 均无问题

  • dry-run E2E 测试通过

  • 单元测试覆盖 pretty 和 json 两种输出格式

  • 本地 lark-cli task +get --task-id xxx 验证命令正常工作

  • go test ./shortcuts/task/... -race passes

  • go vet / gofmt / go mod tidy / golangci-lint all clean

  • Dry-run E2E test passes

  • Unit tests cover both pretty and json output formats

  • Manual lark-cli task +get --task-id xxx verification

Related Issues

  • None

Summary by CodeRabbit

  • New Features
    • Introduced task +get shortcut to retrieve and display individual task details by ID, including summary, description, creation and due dates, status, and URL.

Review Change Stack

Copilot AI review requested due to automatic review settings May 18, 2026 07:57
@github-actions github-actions Bot added domain/task PR touches the task domain size/M Single-domain feat or fix with limited business impact labels May 18, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

📝 Walkthrough

Walkthrough

A new task +get shortcut is added to the task domain, enabling CLI users to fetch and display single task details by ID (GUID or applink URL). The implementation includes DryRun support for API inspection, timestamp parsing, optional field handling, and comprehensive unit and e2e test coverage.

Changes

GetTask Shortcut Feature

Layer / File(s) Summary
GetTask shortcut implementation
shortcuts/task/task_get.go
Exports GetTask shortcut configured for service "task" and command "+get" with read scope. DryRun prepares GET requests with URL-escaped task GUIDs. Execute fetches task details, parses required fields (guid, summary, truncated url) and optional fields (description, due_at, created_at, status) with millisecond-to-RFC3339 timestamp conversion, then writes formatted 📋 Task Detail output.
Unit and e2e test coverage
shortcuts/task/task_get_test.go, tests/cli_e2e/task/task_get_dryrun_test.go
TestGetTask validates shortcut execution with mocked API for both pretty and json formats. TestTask_GetDryRun e2e test validates dry-run request generation for task IDs as both GUID and applink URL, verifying HTTP method, resolved URL path, and user_id_type=open_id in generated API calls.
Register GetTask in shortcuts list
shortcuts/task/shortcuts.go
GetTask is added to the Shortcuts() slice alongside existing task/tasklist commands.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • larksuite/cli#377: Adds multiple other task shortcuts (SetAncestorTask, GetRelatedTasks, SearchTask, SubscribeTaskEvent, SearchTasklist) to the same Shortcuts() registration list.
  • larksuite/cli#736: Also modifies shortcuts/task/shortcuts.go to register a new task CLI command (UploadAttachmentTask).

Suggested labels

domain/task, size/M

Suggested reviewers

  • LuckyTerry
  • liangshuo-1
  • tengchengwei

Poem

🐰 A bunny hops through tasks with glee,
With +get it fetches, quick as can be,
RFC dates parsed from timestamp streams,
Pretty or JSON—fulfilling dreams! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a new task +get shortcut for retrieving single task details by ID, which is the core objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description includes all required sections (Summary, Changes, Test Plan, Related Issues) with comprehensive details about the new task +get shortcut and testing approach.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/task/task_get.go`:
- Around line 31-34: The code is using extractTaskGuid(runtime.Str("task-id"))
without validating that the result is a real GUID, so applink URLs lacking a
guid query can be passed as the taskId; add a guard before PathEscape/GET: call
extractTaskGuid into a local (e.g., raw := runtime.Str("task-id"); guid :=
extractTaskGuid(raw)), then validate guid (e.g., ensure it differs from the raw
URL or matches the expected GUID pattern and does not contain URL characters
like "http", "/", or "?"); if validation fails, return a clear validation error
instead of building the API request that uses taskId; update the same logic for
the other occurrence referenced (lines 38-43) so both places validate before
calling common.NewDryRunAPI().GET(...) with taskId.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e7bbfee1-2f92-49b9-abfe-a0341277c429

📥 Commits

Reviewing files that changed from the base of the PR and between 33c292c and 27f5c87.

📒 Files selected for processing (4)
  • shortcuts/task/shortcuts.go
  • shortcuts/task/task_get.go
  • shortcuts/task/task_get_test.go
  • tests/cli_e2e/task/task_get_dryrun_test.go

Comment thread shortcuts/task/task_get.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a missing “fetch single task by ID” capability to the task shortcuts by exposing the existing internal getTaskDetail helper as a standalone task +get shortcut, along with unit and E2E dry-run coverage.

Changes:

  • Added new task +get shortcut supporting --task-id (GUID or applink URL) with formatted output.
  • Registered GetTask in the task shortcut registry.
  • Added unit tests for pretty/json output and an E2E dry-run test covering GUID + applink URL parsing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/cli_e2e/task/task_get_dryrun_test.go Adds dry-run E2E coverage for task +get request shape and applink GUID extraction.
shortcuts/task/task_get.go Implements the new GetTask shortcut (dry-run + execute output formatting).
shortcuts/task/task_get_test.go Adds unit tests validating pretty and JSON output for the new shortcut.
shortcuts/task/shortcuts.go Registers GetTask in Shortcuts() so the command becomes available.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread shortcuts/task/task_get.go
Comment thread tests/cli_e2e/task/task_get_dryrun_test.go
@zero-my
Copy link
Copy Markdown
Collaborator

zero-my commented May 20, 2026

感谢你的贡献,也欢迎继续给 larksuite/cli 提 PR。
这个改动本身做得很认真,不过非常抱歉这个 PR 我无法approve。主要原因是从接口分层上看, task tasks get 这个基础 API 已经完整覆盖了“按 ID 获取任务详情”的能力,这类能力更适合放在基础 API 层,而不是再额外提供一个 shortcut。我们更希望 shortcut 承载的是更高层、场景化、编排型的能力,而不是对已有基础 API 做一层近似一对一的包装。在这个前提下,新增 task +get 的必要性不强,反而会增加命令表面积和后续维护成本。
综上所述,这次先不合并,但还是非常感谢你的投入,也欢迎继续贡献更符合 shortcut 定位的能力。

@zero-my zero-my closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/task PR touches the task domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants