{"record":{"id":"ea65dc51acb9ee87","repo":"multica-ai/multica","slug":"create-trigger-w","errorCode":null,"errorMessage":"create trigger: %w","messagePattern":"create trigger: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_autopilot.go","lineNumber":585,"sourceCode":"\t\tif v, _ := cmd.Flags().GetString(\"timezone\"); v != \"\" {\n\t\t\tbody[\"timezone\"] = v\n\t\t}\n\t}\n\tif v, _ := cmd.Flags().GetString(\"label\"); v != \"\" {\n\t\tbody[\"label\"] = v\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())\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 result map[string]any\n\tif err := client.PostJSON(ctx, \"/api/autopilots/\"+autopilotRef.ID+\"/triggers\", body, &result); err != nil {\n\t\treturn fmt.Errorf(\"create trigger: %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(\"Trigger created: %s (kind=%s)\\n\", strVal(result, \"id\"), strVal(result, \"kind\"))\n\tif kind == \"webhook\" {\n\t\tprintWebhookURL(client, result)\n\t}\n\treturn nil\n}\n\n// printWebhookURL emits the webhook URL with the priority webhook_url >\n// composed-from-base. Keeps the table-output flow useful — without this the\n// table renderer drops the most important new piece of information.\nfunc printWebhookURL(client *cli.APIClient, trigger map[string]any) {\n\tif u := strVal(trigger, \"webhook_url\"); u != \"\" {","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_autopilot.go#L567-L603","documentation":"Wrapped error from POST /api/autopilots/{id}/triggers in `multica autopilot trigger add`. The autopilot resolved and the body {kind, cron_expression?, timezone?, label?} was built; failure means the server rejected the trigger or the request failed in transit. Typical server-side rejections: invalid cron expression, unknown timezone, too many triggers, or permission denied.","triggerScenarios":"POST returning 400 for a syntactically invalid cron_expression or unknown IANA timezone name; 403 when the token cannot manage triggers; 404 when the autopilot was deleted after resolution; 409 when a schedule/webhook limit is exceeded; network/timeout failure under cli.APIContext.","commonSituations":"Using 6-field Quartz cron where the server expects 5-field; typos in timezones like 'Europe/Berlinn'; hitting a per-autopilot trigger cap; expired token.","solutions":["Read the wrapped response body — cron/timezone syntax errors are called out specifically","Validate the cron expression locally (crontab.guru or `cronexpr` semantics) and use an IANA tz database name","Confirm permissions and that the autopilot still exists","Retry once on transient 5xx/network failures"],"exampleFix":"// before\nmultica autopilot trigger add my-pilot --kind schedule --cron '0 9 * * *' --timezone Europe/Berlinn\n// create trigger: request failed: 400: unknown timezone \"Europe/Berlinn\"\n\n// after\nmultica autopilot trigger add my-pilot --kind schedule --cron '0 9 * * *' --timezone Europe/Berlin","handlingStrategy":"try-catch","validationCode":"# Pre-validate cron field count and timezone name before the call\n[ \"$(echo \"$CRON\" | awk '{print NF}')\" -eq 5 ] || { echo \"cron must have 5 fields\" >&2; exit 2; }\nzoneinfo -l 2>/dev/null | grep -qx \"$TZ\" || echo \"warning: '$TZ' not in local tz database\"","typeGuard":null,"tryCatchPattern":"Capture stderr and branch on the wrapped cause: 400 cron/timezone -> fix input and rerun; 401/403 -> re-auth; 5xx/network -> single bounded retry; 404 -> re-resolve autopilot.","preventionTips":["Use standard 5-field cron and IANA timezone names","Centralize trigger creation in scripts that validate inputs first","Log the full wrapped error — the server body names the offending field"],"tags":["go","cli","http-post","cron","timezone","triggers"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}