multica-ai/multica · error

create trigger: %w

Error message

create trigger: %w

What it means

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.

Source

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

		if v, _ := cmd.Flags().GetString("timezone"); v != "" {
			body["timezone"] = v
		}
	}
	if v, _ := cmd.Flags().GetString("label"); v != "" {
		body["label"] = v
	}

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

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

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

	output, _ := cmd.Flags().GetString("output")
	if output == "json" {
		return cli.PrintJSON(os.Stdout, result)
	}
	fmt.Printf("Trigger created: %s (kind=%s)\n", strVal(result, "id"), strVal(result, "kind"))
	if kind == "webhook" {
		printWebhookURL(client, result)
	}
	return nil
}

// printWebhookURL emits the webhook URL with the priority webhook_url >
// composed-from-base. Keeps the table-output flow useful — without this the
// table renderer drops the most important new piece of information.
func printWebhookURL(client *cli.APIClient, trigger map[string]any) {
	if u := strVal(trigger, "webhook_url"); u != "" {

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Read the wrapped response body — cron/timezone syntax errors are called out specifically
  2. Validate the cron expression locally (crontab.guru or `cronexpr` semantics) and use an IANA tz database name
  3. Confirm permissions and that the autopilot still exists
  4. Retry once on transient 5xx/network failures

Example fix

// before
multica autopilot trigger add my-pilot --kind schedule --cron '0 9 * * *' --timezone Europe/Berlinn
// create trigger: request failed: 400: unknown timezone "Europe/Berlinn"

// after
multica autopilot trigger add my-pilot --kind schedule --cron '0 9 * * *' --timezone Europe/Berlin
Defensive patterns

Strategy: try-catch

Validate before calling

# Pre-validate cron field count and timezone name before the call
[ "$(echo "$CRON" | awk '{print NF}')" -eq 5 ] || { echo "cron must have 5 fields" >&2; exit 2; }
zoneinfo -l 2>/dev/null | grep -qx "$TZ" || echo "warning: '$TZ' not in local tz database"

Try / catch

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.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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