multica-ai/multica · error

trigger autopilot: %w

Error message

trigger autopilot: %w

What it means

Wrapped error from POST /api/autopilots/{id}/trigger in `multica autopilot trigger`. After the autopilot reference resolves successfully, the CLI asks the server to start a run and PostJSON fails on any non-2xx status, network error, or JSON decode problem. The server rejects triggers for autopilots that are paused, archived, have no runnable configuration, or when the caller lacks permission.

Source

Thrown at server/cmd/multica/cmd_autopilot.go:472

}

func runAutopilotTrigger(cmd *cobra.Command, args []string) error {
	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}

	ctx, cancel := context.WithTimeout(context.Background(), cli.AtLeastAPITimeout(30*time.Second))
	defer cancel()

	autopilotRef, err := resolveAutopilotID(ctx, client, args[0])
	if err != nil {
		return fmt.Errorf("resolve autopilot: %w", err)
	}

	var run map[string]any
	if err := client.PostJSON(ctx, "/api/autopilots/"+autopilotRef.ID+"/trigger", nil, &run); err != nil {
		return fmt.Errorf("trigger autopilot: %w", err)
	}

	output, _ := cmd.Flags().GetString("output")
	if output == "json" {
		return cli.PrintJSON(os.Stdout, run)
	}
	fmt.Printf("Autopilot triggered: run %s (status: %s)\n", strVal(run, "id"), strVal(run, "status"))
	return nil
}

func runAutopilotRuns(cmd *cobra.Command, args []string) error {
	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}

	ctx, cancel := cli.APIContext(context.Background())
	defer cancel()

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Read the wrapped HTTP status: 409 means paused/archived/duplicate run — resume or wait for the active run
  2. Re-verify the autopilot exists and is active via `multica autopilots list` or GET /api/autopilots/{id}
  3. For deadline errors, raise the timeout flag/env used by AtLeastAPITimeout and retry once
  4. For 401/403, refresh credentials with `multica auth login` (or equivalent) and confirm the token's workspace role

Example fix

// before
multica autopilot trigger my-pilot
// trigger autopilot: request failed: 409 Conflict: autopilot is paused

// after
multica autopilot update my-pilot --status active
multica autopilot trigger my-pilot
Defensive patterns

Strategy: retry

Validate before calling

curl -s -o /dev/null -w '%{http_code}' -H "Authorization: Bearer $TOKEN" "$API/api/autopilots/$ID" | grep -q 200 || echo "autopilot not reachable — do not trigger"

Try / catch

Wrap the CLI call in a script; on failure, inspect stderr for the wrapped status. Retry at most once, and only when the message indicates 5xx or timeout — never retry 4xx.

Prevention

When it happens

Trigger: POST /api/autopilots/{id}/trigger returning 404 (autopilot deleted between resolve and trigger), 409 (autopilot paused/archived or a run already in progress), 400 (invalid trigger payload), 401/403 (token lacks trigger permission), or the request exceeding the 30s AtLeastAPITimeout on a slow server.

Common situations: Triggering an autopilot that was paused in the UI; expired or under-privileged API token; server restart mid-request; slow scheduler causing the context deadline to fire before the run record is created.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/85c1b234abd8a897. Report an issue: GitHub.