Skip to content

fix(task): always send completed filter in +get-my-tasks#172

Open
VedantMadane wants to merge 1 commit intolarksuite:mainfrom
VedantMadane:fix/task-complete-default
Open

fix(task): always send completed filter in +get-my-tasks#172
VedantMadane wants to merge 1 commit intolarksuite:mainfrom
VedantMadane:fix/task-complete-default

Conversation

@VedantMadane
Copy link
Copy Markdown

@VedantMadane VedantMadane commented Apr 1, 2026

Fixes #164

Problem

lark-cli task +get-my-tasks returns both completed and incomplete tasks when --complete is omitted. The help text says default is false, but the code only sends the completed query parameter when --complete is explicitly passed. When omitted, no filter is sent and the API returns everything.

Fix

Always send the completed parameter using the flag's value. Since Go's bool zero value is false, omitting --complete now sends completed=false to the API, matching the documented behavior.

Before (11 lines):

if runtime.Cmd.Flags().Changed("complete") {
    if runtime.Bool("complete") {
        queryParams.Set("completed", "true")
    } else {
        queryParams.Set("completed", "false")
    }
}

After (1 line):

queryParams.Set("completed", strconv.FormatBool(runtime.Bool("complete")))

Same fix applied to both Execute and DryRun functions.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed task completion status filtering to ensure consistent application across all task retrieval and query scenarios. The completion filter now reliably applies in all cases, resolving previous inconsistencies and improving the reliability and accuracy of task query results.
  • Refactor

    • Simplified task parameter handling by removing redundant conditional logic.

When --complete is omitted, the completed query parameter was not sent
to the API, causing it to return all tasks (completed + incomplete)
instead of defaulting to incomplete-only as documented.

Always send completed=false when the flag is unset so the behavior
matches the help text.

Fixes larksuite#164
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4ce07d67-a2e4-4ef4-b6c3-5dd2615de019

📥 Commits

Reviewing files that changed from the base of the PR and between c4851a5 and 23e3486.

📒 Files selected for processing (1)
  • shortcuts/task/task_get_my_tasks.go

📝 Walkthrough

Walkthrough

Modified task_get_my_tasks.go to always include the completed parameter when building API requests, defaulting to false when the flag is omitted. Previously, the parameter was omitted entirely when not explicitly set, causing the API to return all tasks regardless of completion status.

Changes

Cohort / File(s) Summary
Bug Fix: Always Include Completed Parameter
shortcuts/task/task_get_my_tasks.go
Removed conditional checks around the complete flag. The completed parameter is now always set in both DryRun and Execute methods, defaulting to false when the flag is not provided, fixing the behavior where omitting the flag returned all tasks instead of only incomplete ones.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A flag once lost, now always seen,
No more ambiguous in-between!
Complete or not, we now declare,
Default to false with gentle care. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: always sending the completed filter in the get-my-tasks command, which directly addresses the bug.
Linked Issues check ✅ Passed The code change aligns with issue #164 requirements: it ensures the completed parameter is always sent with the flag's value (defaulting to false), matching the documented behavior.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the completed filter behavior in get-my-tasks as specified in issue #164; no extraneous modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 1, 2026

Greptile Summary

This PR fixes a bug where lark-cli task +get-my-tasks returned both completed and incomplete tasks by default, instead of only incomplete ones as documented. The root cause was that the completed query parameter was only sent to the Lark API when --complete was explicitly passed on the command line; omitting it caused the API to return all tasks.

The fix removes the runtime.Cmd.Flags().Changed(\"complete\") guard in both DryRun and Execute, so completed is always included in the request. Because Go's zero value for bool is false, the default behaviour now correctly sends completed=false, matching the documented \"default is false\" help text.

Key changes:

  • Execute: replaced the 6-line if/else block with a single queryParams.Set(\"completed\", strconv.FormatBool(runtime.Bool(\"complete\"))) call.
  • DryRun: removed the wrapping if Flags().Changed check; the existing params[\"completed\"] = runtime.Bool(\"complete\") assignment is now unconditional.
  • No new dependencies or interface changes; the strconv package was already imported.

Confidence Score: 5/5

Safe to merge — the change is minimal, well-scoped, and correctly aligns runtime behaviour with documented defaults.

The fix is a straightforward removal of a conditional guard that was causing the documented default to be silently ignored. Both changed paths (Execute and DryRun) are handled consistently. There are no new dependencies, no schema changes, and no risk of regressions beyond the intentional behaviour change (incomplete-only by default). All remaining observations are P2 or lower, so the score is 5.

No files require special attention.

Important Files Changed

Filename Overview
shortcuts/task/task_get_my_tasks.go Removes the Flags().Changed("complete") guard and always sends completed as a query param; Execute uses strconv.FormatBool, DryRun passes the raw bool — both are consistent with their respective param-map types and correctly fix the default-false behaviour.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI
    participant LarkAPI

    Note over User,LarkAPI: Before fix (--complete omitted)
    User->>CLI: lark-cli task +get-my-tasks
    CLI->>LarkAPI: GET /open-apis/task/v2/tasks?type=my_tasks&user_id_type=open_id&page_size=50
    LarkAPI-->>CLI: all tasks (completed + incomplete)

    Note over User,LarkAPI: After fix (--complete omitted)
    User->>CLI: lark-cli task +get-my-tasks
    CLI->>LarkAPI: GET /open-apis/task/v2/tasks?type=my_tasks&user_id_type=open_id&page_size=50&completed=false
    LarkAPI-->>CLI: incomplete tasks only

    Note over User,LarkAPI: After fix (--complete=true)
    User->>CLI: lark-cli task +get-my-tasks --complete=true
    CLI->>LarkAPI: GET /open-apis/task/v2/tasks?type=my_tasks&user_id_type=open_id&page_size=50&completed=true
    LarkAPI-->>CLI: completed tasks only
Loading

Reviews (1): Last reviewed commit: "fix(task): always send completed filter ..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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

2 participants