Skip to content

Commit df7a322

Browse files
committed
fix(cli): remove ignored automation dedup key
1 parent e003669 commit df7a322

3 files changed

Lines changed: 21 additions & 18 deletions

File tree

internal/cli/automation.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ func buildAutomationFireCmd(use string) *cobra.Command {
458458
var (
459459
token string
460460
text string
461-
dedupKey string
462461
dataJSON string
463462
)
464463

@@ -468,12 +467,11 @@ func buildAutomationFireCmd(use string) *cobra.Command {
468467
Long: `Trigger an Automation run through its HTTP POST trigger.
469468
470469
The trigger authenticates with its one-time token, not the account app key. Pass
471-
--token or set FLASHDUTY_AUTOMATION_TRIGGER_TOKEN. Use --dedup-key to make
472-
retries idempotent for the same trigger.`,
470+
--token or set FLASHDUTY_AUTOMATION_TRIGGER_TOKEN.`,
473471
Args: requireExactArg("trigger_id"),
474472
RunE: func(cmd *cobra.Command, args []string) error {
475473
return runCommand(cmd, args, func(ctx *RunContext) error {
476-
out, err := runAutomationFire(ctx, ctx.Args[0], token, text, dedupKey, dataJSON)
474+
out, err := runAutomationFire(ctx, ctx.Args[0], token, text, dataJSON)
477475
if err != nil {
478476
return err
479477
}
@@ -484,19 +482,15 @@ retries idempotent for the same trigger.`,
484482

485483
cmd.Flags().StringVar(&token, "token", "", "HTTP POST trigger token; defaults to FLASHDUTY_AUTOMATION_TRIGGER_TOKEN")
486484
cmd.Flags().StringVar(&text, "text", "", "Context text passed to this run")
487-
cmd.Flags().StringVar(&dedupKey, "dedup-key", "", "Optional idempotency key")
488485
cmd.Flags().StringVar(&dataJSON, "data", "", "Full request body as JSON; typed flags override its fields. Accepts inline JSON, or - to read stdin.")
489486
return cmd
490487
}
491488

492-
func runAutomationFire(ctx *RunContext, triggerID, token, text, dedupKey, dataJSON string) (*flashduty.AutomationFireAPITriggerResponse, error) {
489+
func runAutomationFire(ctx *RunContext, triggerID, token, text, dataJSON string) (*flashduty.AutomationFireAPITriggerResponse, error) {
493490
body, err := genAssembleBody(dataJSON, func(body map[string]any) error {
494491
if ctx.Cmd.Flags().Changed("text") {
495492
body["text"] = text
496493
}
497-
if ctx.Cmd.Flags().Changed("dedup-key") {
498-
body["dedup_key"] = dedupKey
499-
}
500494
return nil
501495
})
502496
if err != nil {

internal/cli/automation_test.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,15 @@ func TestAutomationFireSendsBearerToken(t *testing.T) {
124124
saveAndResetGlobals(t)
125125
stub := newGFStub(t)
126126
stub.data = map[string]any{
127-
"rule_id": "auto_123",
128-
"run_id": "run_123",
129-
"status": "queued",
130-
"trigger_kind": "http_post",
127+
"type": "routine_fire",
128+
"session_id": "sess_123",
129+
"session_url": "/safari/session/sess_123",
131130
}
132131

133132
_, err := execCommand(
134133
"automation", "fire", "auttrig_123",
135134
"--token", "token-123",
136135
"--text", "manual test",
137-
"--dedup-key", "once",
138136
"--json",
139137
)
140138
if err != nil {
@@ -147,7 +145,20 @@ func TestAutomationFireSendsBearerToken(t *testing.T) {
147145
t.Fatalf("[automation-fire] authorization = %q", stub.lastAuthorization)
148146
}
149147
assertBody(t, stub.lastBody, "text", "manual test")
150-
assertBody(t, stub.lastBody, "dedup_key", "once")
148+
}
149+
150+
func TestAutomationFireDoesNotExposeIgnoredDedupKey(t *testing.T) {
151+
saveAndResetGlobals(t)
152+
newGFStub(t)
153+
154+
_, err := execCommand(
155+
"automation", "fire", "auttrig_123",
156+
"--token", "token-123",
157+
"--dedup-key", "once",
158+
)
159+
if err == nil || !strings.Contains(err.Error(), "unknown flag: --dedup-key") {
160+
t.Fatalf("expected dedup-key to be rejected, got %v", err)
161+
}
151162
}
152163

153164
func TestSafariAutomationTriggerFirePathCommand(t *testing.T) {

skills/flashduty/reference/automation.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ fduty automation delete <rule-id> --force
9797
fduty automation fire <trigger-id> \
9898
--token "$FLASHDUTY_AUTOMATION_TRIGGER_TOKEN" \
9999
--text "manual validation run" \
100-
--dedup-key "manual-$(date +%Y%m%d%H%M)" \
101100
--output-format toon
102101
```
103102

104-
`--dedup-key` makes retries idempotent for the same trigger. Do not invent a token. If it is missing, rotate the trigger token through `update` or ask the user to provide it through their secure shell/environment, not in chat.
103+
The trigger API has no idempotency key: retry only when the failed call is known not to have reached the server. Do not invent a token. If it is missing, rotate the trigger token through `update` or ask the user to provide it through their secure shell/environment, not in chat.
105104

106105
<!-- GENERATED:automation START · 由 fduty __dump-commands 同步 · 勿手改 fence 内 -->
107106

@@ -127,7 +126,6 @@ Delete an Automation
127126

128127
### fire <trigger_id>
129128
Fire an Automation HTTP POST trigger
130-
- `--dedup-key` string
131129
- `--text` string
132130
- `--token` string
133131

0 commit comments

Comments
 (0)