{"record":{"id":"e913b187461ec185","repo":"multica-ai/multica","slug":"rotate-webhook-url-w","errorCode":null,"errorMessage":"rotate webhook url: %w","messagePattern":"rotate webhook url: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_autopilot.go","lineNumber":650,"sourceCode":"\t// version uses an AlertDialog; the CLI mirrors that with a y/N prompt\n\t// unless --yes was passed for scripted use. Style matches confirmOverwrite\n\t// in cmd_setup.go.\n\tyes, _ := cmd.Flags().GetBool(\"yes\")\n\tif !yes {\n\t\tfmt.Fprintln(os.Stderr, \"This will invalidate the current webhook URL immediately. Continue? [y/N] \")\n\t\treader := bufio.NewReader(os.Stdin)\n\t\tanswer, _ := reader.ReadString('\\n')\n\t\tanswer = strings.TrimSpace(strings.ToLower(answer))\n\t\tif answer != \"y\" && answer != \"yes\" {\n\t\t\tfmt.Fprintln(os.Stderr, \"Aborted.\")\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tvar result map[string]any\n\tpath := \"/api/autopilots/\" + autopilotRef.ID + \"/triggers/\" + triggerRef.ID + \"/rotate-webhook-token\"\n\tif err := client.PostJSON(ctx, path, nil, &result); err != nil {\n\t\treturn fmt.Errorf(\"rotate webhook url: %w\", err)\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, result)\n\t}\n\tfmt.Printf(\"Webhook URL rotated for trigger %s\\n\", strVal(result, \"id\"))\n\tprintWebhookURL(client, result)\n\treturn nil\n}\n\nfunc runAutopilotTriggerUpdate(cmd *cobra.Command, args []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tbody := map[string]any{}","sourceCodeStart":632,"sourceCodeEnd":668,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_autopilot.go#L632-L668","documentation":"Wrapped error from POST /api/autopilots/{id}/triggers/{triggerID}/rotate-webhook-token in `multica autopilot trigger rotate-webhook-url`. Both references resolved and the user confirmed (or passed --yes); the server-side rotation of the webhook secret failed. Successful rotation returns a new URL which the CLI prints via printWebhookURL.","triggerScenarios":"POST returning 400 when the trigger is not kind=webhook (schedule triggers have no token to rotate), 404 when the trigger was deleted between resolution and rotation, 403 without trigger-management permission, 409 on concurrent rotation, or a network/timeout failure under cli.APIContext.","commonSituations":"Rotating a schedule trigger by mistake; token deleted in the UI concurrently; under-privileged service account; old integrations still posting to the previous URL after rotation (expected, but often discovered here when re-checking the trigger).","solutions":["Verify the trigger kind is webhook: GET /api/autopilots/{id} and check triggers[].kind","Re-resolve the trigger ID — 404 usually means it was deleted concurrently","Re-run with --yes after confirming; the failure left the old URL intact (rotation is server-atomic)","Fix auth/permissions on 401/403"],"exampleFix":"// before\nmultica autopilot trigger rotate-webhook-url my-pilot sched-trig --yes\n// rotate webhook url: request failed: 400: trigger is not a webhook trigger\n\n// after\nmultica autopilot trigger rotate-webhook-url my-pilot webhook-trig-uuid --yes","handlingStrategy":"try-catch","validationCode":"KIND=$(curl -s -H \"Authorization: Bearer $TOKEN\" \"$API/api/autopilots/$ID\" | jq -r --arg t \"$TRIGGER\" \".triggers[] | select(.id==\\\"$t\\\") | .kind\")\n[ \"$KIND\" = \"webhook\" ] || { echo \"trigger $TRIGGER is kind=$KIND, not webhook\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"Branch on wrapped status: 400 not-a-webhook -> pick the right trigger; 404 -> re-resolve (trigger gone); 401/403 -> fix credentials; 5xx/network -> one retry. Rotation is atomic server-side: a failed call leaves the old URL valid.","preventionTips":["Verify kind=webhook before rotating","Immediately update downstream integrations after a successful rotation — the old URL is invalid from that moment","Schedule rotations; do not rotate ad hoc during incident response"],"tags":["go","cli","http-post","webhook","secret-rotation","triggers"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}