Skip to content

fix(task): default +get-my-tasks to incomplete results#309

Closed
OwenYWT wants to merge 1 commit into
larksuite:mainfrom
OwenYWT:codex/task-default-incomplete
Closed

fix(task): default +get-my-tasks to incomplete results#309
OwenYWT wants to merge 1 commit into
larksuite:mainfrom
OwenYWT:codex/task-default-incomplete

Conversation

@OwenYWT

@OwenYWT OwenYWT commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Make task +get-my-tasks default to incomplete tasks when --complete is omitted, matching the command help and issue expectation.

Changes

  • always send the completed filter, defaulting to false when --complete is omitted
  • keep --complete=true and --complete=false as explicit overrides
  • add regression tests covering omitted, true, and false completion filters
  • update the task skill reference to document the corrected default behavior

Related Issues

Test Plan

  • GOCACHE=/tmp/go-build-cache GOMODCACHE=/tmp/go-mod-cache /opt/homebrew/opt/go/bin/go test ./shortcuts/task -run 'TestGetMyTasks_CompletionFilterDefaultsToIncomplete|TestGetMyTasks_LocalTimeFormatting'
  • GOCACHE=/tmp/go-build-cache GOMODCACHE=/tmp/go-mod-cache /opt/homebrew/opt/go/bin/go test ./shortcuts/task

Summary by CodeRabbit

Release Notes

  • Changes

    • Modified --complete flag behavior: the API request now always includes the completion filter instead of omitting it when the flag is not provided.
    • Default behavior updated: omitting --complete now queries incomplete tasks only (previously returned all tasks).
  • Documentation

    • Clarified --complete flag documentation to reflect the new default filtering behavior.

@CLAassistant

CLAassistant commented Apr 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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 Apr 8, 2026
@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR fixes a bug where omitting the --complete flag in the get-my-tasks command returned all tasks instead of defaulting to incomplete tasks as documented. The implementation now unconditionally includes the completed query parameter with the boolean value instead of conditionally omitting it when the flag is unset.

Changes

Cohort / File(s) Summary
Implementation Fix
shortcuts/task/task_get_my_tasks.go
Removed conditional logic that skipped setting the completed query parameter when the flag wasn't explicitly changed. Now unconditionally sets completed=false (or the flag value) using strconv.FormatBool() to ensure API always receives the parameter.
Test Coverage
shortcuts/task/task_get_my_tasks_test.go
Added new test suite TestGetMyTasks_CompletionFilterDefaultsToIncomplete with three test cases validating that omitting --complete defaults to completed=false, explicit --complete=false maintains incomplete filter, and --complete=true switches to completed filter.
Documentation
skills/lark-task/references/lark-task-get-my-tasks.md
Updated parameter documentation to clarify that omitting --complete defaults to querying incomplete tasks (false) rather than returning all tasks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

domain/task, size/M

Suggested reviewers

  • LuckyTerry
  • liangshuo-1
  • tengchengwei

Poem

🐰 A flag that wandered, lost and unclear,
Now defaults to false—incomplete tasks appear!
With tests to confirm and docs fresh and bright,
The rabbit hops merrily, all is set right. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 clearly and concisely describes the main change: fixing the default behavior of get-my-tasks to return incomplete results.
Description check ✅ Passed The description follows the repository template with Summary, Changes, Related Issues, and Test Plan sections all properly filled out.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #164: unconditionally sends the completed filter defaulting to false, preserves explicit overrides, adds regression tests, and updates documentation.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the completion filter default behavior as specified in issue #164; no out-of-scope modifications detected.

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

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

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

@greptile-apps

greptile-apps Bot commented Apr 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a behavioral bug where omitting --complete from +get-my-tasks returned all tasks (complete + incomplete) instead of defaulting to incomplete-only. The fix unconditionally sends completed=false to the API when --complete is not specified, matching the documented help text and user expectations.

Confidence Score: 5/5

This PR is safe to merge — it correctly fixes a filter-defaulting bug, aligns behavior with documentation, and adds focused regression tests.

The change is minimal and targeted. runtime.Bool("complete") returns false by default when the flag is not passed, so strconv.FormatBool(false) always produces the correct default. All three filter scenarios are covered by new tests, and reg.Verify(t) via t.Cleanup confirms stubs were hit. No P0 or P1 findings.

No files require special attention.

Vulnerabilities

No security concerns identified.

Important Files Changed

Filename Overview
shortcuts/task/task_get_my_tasks.go Removes the Flags().Changed("complete") guard in both DryRun and Execute, so completed is always sent — defaulting to false — regardless of whether the flag was explicitly passed.
shortcuts/task/task_get_my_tasks_test.go Adds three regression tests covering omitted, explicit-false, and explicit-true completion filters using the httpmock substring URL matcher.
skills/lark-task/references/lark-task-get-my-tasks.md Updates the --complete parameter description to document that omitting the flag now defaults to incomplete tasks.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["+get-my-tasks invoked"] --> B{--complete flag\nexplicitly set?}
    B -- "Yes (--complete=true)" --> C["completed=true\nsent to API"]
    B -- "Yes (--complete=false)" --> D["completed=false\nsent to API"]
    B -- "No (omitted)" --> D
    C --> E["API returns completed tasks"]
    D --> F["API returns incomplete tasks (default)"]
Loading

Reviews (1): Last reviewed commit: "fix(task): default +get-my-tasks to inco..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 the current code and only fix it if needed.

Inline comments:
In `@shortcuts/task/task_get_my_tasks_test.go`:
- Around line 118-120: The test helper doesn't isolate CLI config state causing
machine-local cache interference; modify taskTestConfig (used by
taskShortcutTestFactory) to set a dedicated temp config dir for each test by
calling t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) so config state is
isolated, ensuring taskShortcutTestFactory and any callers (e.g.,
task_get_my_tasks_test.go helpers) use cmdutil.TestFactory(t, config) with the
per-test env override.
🪄 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: f6e7ecbf-850c-491e-b310-933d18a8e05b

📥 Commits

Reviewing files that changed from the base of the PR and between 12bb01a and 3d9d19b.

📒 Files selected for processing (3)
  • shortcuts/task/task_get_my_tasks.go
  • shortcuts/task/task_get_my_tasks_test.go
  • skills/lark-task/references/lark-task-get-my-tasks.md

Comment on lines +118 to +120
f, stdout, _, reg := taskShortcutTestFactory(t)
warmTenantToken(t, f, reg)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether task test factory helper follows required test setup conventions.

# 1) Locate helper definition and inspect nearby lines.
rg -n -C4 'func\s+taskShortcutTestFactory\s*\('

# 2) Check usage of required factory constructor.
rg -n -C3 'cmdutil\.TestFactory\s*\('

# 3) Check test config isolation via temp config dir env var.
rg -n -C3 'LARKSUITE_CLI_CONFIG_DIR'

Repository: larksuite/cli

Length of output: 50370


🏁 Script executed:

#!/bin/bash
# Search for taskTestConfig definition and nearby code
rg -n -B2 -A10 'func\s+taskTestConfig\s*\('

Repository: larksuite/cli

Length of output: 926


🏁 Script executed:

#!/bin/bash
# Check other test config functions
rg -n -B1 -A8 'func\s+(driveTestConfig|mailTestConfig|defaultConfig)\s*\(' shortcuts/

# Also check the internal registry test pattern mentioned in learnings
rg -n -B2 -A8 'func\s+ensureFreshRegistry\s*\('

Repository: larksuite/cli

Length of output: 3307


🏁 Script executed:

#!/bin/bash
# Search for ensureFreshRegistry in internal/registry
rg -n -B2 -A10 'ensureFreshRegistry' internal/registry/

Repository: larksuite/cli

Length of output: 39


🏁 Script executed:

#!/bin/bash
# Search for the pattern in internal/registry/registry_test.go
rg -n -A10 'LARKSUITE_CLI_CONFIG_DIR' internal/registry/

Repository: larksuite/cli

Length of output: 5165


🏁 Script executed:

#!/bin/bash
# Check the actual test function at lines 118-120 in task_get_my_tasks_test.go
rg -n -B10 -A5 'taskShortcutTestFactory' shortcuts/task/task_get_my_tasks_test.go | head -40

Repository: larksuite/cli

Length of output: 1005


Add config state isolation to test setup helper.

The taskShortcutTestFactory helper correctly uses cmdutil.TestFactory(t, config), satisfying the first guideline. However, taskTestConfig(t) does not isolate config state per coding guidelines. Add t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) to the helper to prevent machine-local cache interference, following the pattern established in internal/registry/remote_test.go.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/task/task_get_my_tasks_test.go` around lines 118 - 120, The test
helper doesn't isolate CLI config state causing machine-local cache
interference; modify taskTestConfig (used by taskShortcutTestFactory) to set a
dedicated temp config dir for each test by calling
t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) so config state is isolated,
ensuring taskShortcutTestFactory and any callers (e.g.,
task_get_my_tasks_test.go helpers) use cmdutil.TestFactory(t, config) with the
per-test env override.

@zero-my

zero-my commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

Hi @OwenYWT,

Thank you so much for your PR and for looking into this issue! We really appreciate your effort in adding the tests and trying to fix this behavior.

After discussing this internally (similar to what was brought up in issue #172), we realized that the core issue was actually a mistake in our documentation and help text, rather than a bug in the code logic itself. If we were to change the default behavior to explicitly send completed=false when the flag is omitted, it would remove the ability for users to fetch both completed and incomplete tasks simultaneously.

To preserve the ability to query all tasks, we have decided to keep the original logic (omitting the parameter when the flag is not passed) but update the documentation and the command's help text to accurately reflect this three-state behavior (omitted = both, true = completed, false = incomplete).

The documentation and help text fix has been merged in PR #310.

Again, thank you for your keen eye and for taking the time to contribute to the project! We look forward to seeing more of your contributions in the future.

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.

task +get-my-tasks: omitting --complete returns all tasks instead of defaulting to false

3 participants