Skip to content

Fix update methods silently dropping empty ID arrays#207

Merged
jeremy merged 4 commits intobasecamp:mainfrom
robzolkos:fix-card-unassign-empty-assignees
Mar 20, 2026
Merged

Fix update methods silently dropping empty ID arrays#207
jeremy merged 4 commits intobasecamp:mainfrom
robzolkos:fix-card-unassign-empty-assignees

Conversation

@robzolkos
Copy link
Collaborator

@robzolkos robzolkos commented Mar 19, 2026

Summary

  • Update methods across cards, card steps, todos, and schedule entries used len(slice) > 0 to guard writing assignee/participant/subscriber ID arrays into the request body. This caused empty slices ([]int64{}) — meaning "clear all" — to be silently omitted. The API interprets an absent field as "no change," so clearing the last assignee/participant/subscriber had no effect.
  • Changed all affected guards from len(slice) > 0 to slice != nil, preserving the three-way semantics: nil = don't change, []int64{} = clear all, []int64{1,2} = set specific IDs.
  • Affected: CardsService.Update (AssigneeIDs), CardStepsService.Update (Assignees), TodosService.Update (AssigneeIDs, CompletionSubscriberIDs), SchedulesService.UpdateEntry (ParticipantIDs)

Report: https://3.basecamp.com/2914079/buckets/46292715/card_tables/cards/9696883477


Summary by cubic

Fixes update methods that dropped empty ID arrays, so you can clear assignees, participants, and subscribers. Empty slices are now sent to the API; nil means no change.

  • Bug Fixes
    • Preserve three-way semantics for ID arrays: nil = no change, [] = clear all, [1,2] = set IDs.
    • Applied to CardsService.Update (AssigneeIDs), CardStepsService.Update (Assignees), TodosService.Update (AssigneeIDs, CompletionSubscriberIDs), and SchedulesService.UpdateEntry (ParticipantIDs). Added tests to lock this behavior.
    • Added nil request guard to TodosService.Update to prevent nil-pointer panics and align with other services.

Written for commit b95c1d5. Summary will update on new commits.

The len() > 0 guard on AssigneeIDs/Assignees caused empty slices
(meaning "clear all assignees") to be silently omitted from the
request body. The API treats an absent field as "no change," so
unassigning the last person from a card or step had no effect.

Switch to a nil check so nil means "don't change" and an empty
non-nil slice means "clear all."
Same len() > 0 bug as the card fix — empty slices for AssigneeIDs
and CompletionSubscriberIDs were silently omitted, making it
impossible to clear all assignees or completion subscribers from
a todo.
Same len() > 0 bug — an empty ParticipantIDs slice was silently
omitted, making it impossible to clear all participants from a
schedule entry.
Copilot AI review requested due to automatic review settings March 19, 2026 14:53
@github-actions github-actions bot added go bug Something isn't working labels Mar 19, 2026
Copy link

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 fixes update semantics across the Go Basecamp SDK so that explicitly empty (but non-nil) ID slices are sent in update request bodies, allowing callers to “clear all” assignees/participants/subscribers rather than silently omitting the field and making no change.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Switch slice guards from len(slice) > 0 to slice != nil in update methods to preserve nil vs empty-slice semantics.
  • Add/extend tests ensuring empty slices are encoded as empty arrays (e.g., "assignee_ids":[]) rather than omitted.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
go/pkg/basecamp/todos.go Sends assignee_ids / completion_subscriber_ids whenever the slice is non-nil (including empty).
go/pkg/basecamp/todos_test.go Adds tests asserting empty slices are present in the update request body for todos.
go/pkg/basecamp/schedules.go Sends participant_ids whenever the slice is non-nil (including empty).
go/pkg/basecamp/schedules_test.go Adds a test asserting empty participant IDs are sent in schedule entry updates.
go/pkg/basecamp/cards.go Sends assignee_ids / assignees whenever the slice is non-nil (including empty).
go/pkg/basecamp/cards_test.go Adds tests asserting empty assignee lists are sent for cards and card steps.

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

You can also share your feedback on Copilot code review. Take the survey.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

Other Update methods (Cards, Schedules) already guard against nil
requests. Add the same check to Todos to prevent a nil-pointer panic.
@jeremy jeremy merged commit 55e14df into basecamp:main Mar 20, 2026
39 checks passed
robzolkos added a commit to basecamp/basecamp-cli that referenced this pull request Mar 20, 2026
Picks up basecamp/basecamp-sdk#207 which fixes update methods
silently dropping empty ID slices. Previously, unassigning the
last assignee/participant/subscriber had no effect because the
SDK omitted the empty array from the request body.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants