-
Notifications
You must be signed in to change notification settings - Fork 10
Fix cards column color 404 from missing bucket in URL
#455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1271,7 +1271,7 @@ func newCardsColumnCmd(project, cardTable *string) *cobra.Command { | |
| newCardsColumnUnwatchCmd(), | ||
| newCardsColumnOnHoldCmd(), | ||
| newCardsColumnNoOnHoldCmd(), | ||
| newCardsColumnColorCmd(), | ||
| newCardsColumnColorCmd(project), | ||
| ) | ||
|
|
||
| return cmd | ||
|
|
@@ -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{ | ||
|
|
@@ -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 | ||
| } | ||
| 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
|
||
|
|
||
| col, err := app.Account().CardColumns().Get(cmd.Context(), columnID) | ||
| if err != nil { | ||
| return convertSDKError(err) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
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
projectIDfrom the--in/--projectpointer and only falls back tourlProjectIDif that’s empty, so flags override the URL. Either update the precedence logic to preferurlProjectIDwhen present, or adjust the comment/PR description to reflect the actual behavior to avoid confusion and unexpected bucket selection when both are provided.