Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(cli): show actionable error when workspace_id is missing

Jiang Bohan3046f513003b
diff --git a/server/cmd/multica/cmd_agent.go b/server/cmd/multica/cmd_agent.go
index f62e6228d9..83a292f9fa 100644
--- a/server/cmd/multica/cmd_agent.go
+++ b/server/cmd/multica/cmd_agent.go
@@ -206,6 +206,17 @@ func resolveWorkspaceID(cmd *cobra.Command) string {
return cfg.WorkspaceID
}
+// requireWorkspaceID resolves the workspace ID and returns an error with
+// actionable instructions if it is empty (e.g. user has multiple workspaces
+// but no default configured).
+func requireWorkspaceID(cmd *cobra.Command) (string, error) {
+ id := resolveWorkspaceID(cmd)
+ if id == "" {
+ return "", fmt.Errorf("workspace_id is required: use --workspace-id flag, set MULTICA_WORKSPACE_ID env, or run 'multica config set workspace_id <id>'")
+ }
+ return id, nil
+}
+
// ---------------------------------------------------------------------------
// Agent commands
// ---------------------------------------------------------------------------
@@ -215,15 +226,18 @@ func runAgentList(cmd *cobra.Command, _ []string) error {
if err != nil {
return err
}
+ if client.WorkspaceID == "" {
+ if _, err := requireWorkspaceID(cmd); err != nil {
+ return err
+ }
+ }
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
var agents []map[string]any
params := url.Values{}
- if client.WorkspaceID != "" {
- params.Set("workspace_id", client.WorkspaceID)
- }
+ params.Set("workspace_id", client.WorkspaceID)
if v, _ := cmd.Flags().GetBool("include-archived"); v {
params.Set("include_archived", "true")
}
diff --git a/server/cmd/multica/cmd_issue.go b/server/cmd/multica/cmd_issue.go
index e026e7c075..9122d6553a 100644
--- a/server/cmd/multica/cmd_issue.go
+++ b/server/cmd/multica/cmd_issue.go
@@ -206,10 +206,14 @@ func runIssueList(cmd *cobra.Command, _ []string) error {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
- params := url.Values{}
- if client.WorkspaceID != "" {
- params.Set("workspace_id", client.WorkspaceID)
+ if client.WorkspaceID == "" {
+ if _, err := requireWorkspaceID(cmd); err != nil {
+ return err
+ }
}
+
+ params := url.Values{}
+ params.Set("workspace_id", client.WorkspaceID)
if v, _ := cmd.Flags().GetString("status"); v != "" {
params.Set("status", v)
}