{"record":{"id":"85c1b234abd8a897","repo":"multica-ai/multica","slug":"trigger-autopilot-w","errorCode":null,"errorMessage":"trigger autopilot: %w","messagePattern":"trigger autopilot: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_autopilot.go","lineNumber":472,"sourceCode":"}\n\nfunc runAutopilotTrigger(cmd *cobra.Command, args []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), cli.AtLeastAPITimeout(30*time.Second))\n\tdefer cancel()\n\n\tautopilotRef, err := resolveAutopilotID(ctx, client, args[0])\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolve autopilot: %w\", err)\n\t}\n\n\tvar run map[string]any\n\tif err := client.PostJSON(ctx, \"/api/autopilots/\"+autopilotRef.ID+\"/trigger\", nil, &run); err != nil {\n\t\treturn fmt.Errorf(\"trigger autopilot: %w\", err)\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, run)\n\t}\n\tfmt.Printf(\"Autopilot triggered: run %s (status: %s)\\n\", strVal(run, \"id\"), strVal(run, \"status\"))\n\treturn nil\n}\n\nfunc runAutopilotRuns(cmd *cobra.Command, args []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_autopilot.go#L454-L490","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the wrapped HTTP status: 409 means paused/archived/duplicate run — resume or wait for the active run","Re-verify the autopilot exists and is active via `multica autopilots list` or GET /api/autopilots/{id}","For deadline errors, raise the timeout flag/env used by AtLeastAPITimeout and retry once","For 401/403, refresh credentials with `multica auth login` (or equivalent) and confirm the token's workspace role"],"exampleFix":"// before\nmultica autopilot trigger my-pilot\n// trigger autopilot: request failed: 409 Conflict: autopilot is paused\n\n// after\nmultica autopilot update my-pilot --status active\nmultica autopilot trigger my-pilot","handlingStrategy":"retry","validationCode":"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\"","typeGuard":null,"tryCatchPattern":"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.","preventionTips":["Confirm the autopilot is active (not paused) before triggering","Keep the 30s trigger timeout generous enough for slow schedulers","Check for an in-progress run before requesting another"],"tags":["go","cli","http-post","api","scheduling"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}