Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions internal/commands/cards.go
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ func newCardsColumnCmd(project, cardTable *string) *cobra.Command {
newCardsColumnUnwatchCmd(),
newCardsColumnOnHoldCmd(),
newCardsColumnNoOnHoldCmd(),
newCardsColumnColorCmd(),
newCardsColumnColorCmd(project),
)

return cmd
Expand Down Expand Up @@ -1726,7 +1726,7 @@ You can pass either a column ID or a Basecamp URL:
return cmd
}

func newCardsColumnColorCmd() *cobra.Command {
func newCardsColumnColorCmd(project *string) *cobra.Command {
var color string

cmd := &cobra.Command{
Expand All @@ -1750,14 +1750,43 @@ You can pass either a column ID or a Basecamp URL:
return err
}

// Extract ID from URL if provided
columnIDStr := extractID(args[0])
// Extract ID and project from URL if provided
columnIDStr, urlProjectID := extractWithProject(args[0])
columnID, err := strconv.ParseInt(columnIDStr, 10, 64)
if err != nil {
return output.ErrUsage("Invalid column ID")
}

col, err := app.Account().CardColumns().SetColor(cmd.Context(), columnID, color)
// Resolve project - use URL > flag > config, with interactive fallback.
// The color endpoint requires a bucket-scoped path (PUT /buckets/<id>/card_tables/columns/<id>/color.json).
projectID := *project
if projectID == "" && urlProjectID != "" {
projectID = urlProjectID
}
if projectID == "" {
projectID = app.Flags.Project
Comment on lines +1760 to +1767
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

The project-resolution precedence doesn’t match what’s stated here (and in the PR description). The code initializes projectID from the --in/--project pointer and only falls back to urlProjectID if that’s empty, so flags override the URL. Either update the precedence logic to prefer urlProjectID when present, or adjust the comment/PR description to reflect the actual behavior to avoid confusion and unexpected bucket selection when both are provided.

Copilot uses AI. Check for mistakes.
}
if projectID == "" {
projectID = app.Config.ProjectID
}
if projectID == "" {
if err := ensureProject(cmd, app); err != nil {
return err
}
projectID = app.Config.ProjectID
}

resolvedProjectID, _, err := app.Names.ResolveProject(cmd.Context(), projectID)
if err != nil {
return err
}

path := fmt.Sprintf("/buckets/%s/card_tables/columns/%d/color.json", resolvedProjectID, columnID)
if _, err := app.Account().Put(cmd.Context(), path, map[string]string{"color": color}); err != nil {
return convertSDKError(err)
}
Comment on lines +1784 to +1787
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

This new raw PUT to a bucket-scoped /color.json endpoint is the core of the fix, but there’s no unit test asserting that the command actually issues a PUT to /buckets/<project>/card_tables/columns/<id>/color.json (and that URL-form args populate the bucket). Since cards_test.go already uses custom RoundTrippers for request-path assertions, consider adding a transport-backed test that captures the PUT path/body and validates the bucket segment is present.

Copilot uses AI. Check for mistakes.

col, err := app.Account().CardColumns().Get(cmd.Context(), columnID)
if err != nil {
return convertSDKError(err)
}
Expand Down
3 changes: 2 additions & 1 deletion internal/commands/cards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ func TestCardsColumnColorShowsHelp(t *testing.T) {
// Configure app with project
app.Config.ProjectID = "123"

cmd := newCardsColumnColorCmd()
project := ""
cmd := newCardsColumnColorCmd(&project)

err := executeCommand(cmd, app, "456") // column ID but no --color
assert.NoError(t, err, "expected help output, not error")
Expand Down
Loading