Skip to content

Commit 2cb6982

Browse files
authored
Fix activity command flag bugs and help text inconsistencies (#974)
## What was changed - activity pause silently ignored the `--identity` flag, always sending the global client identity instead of the per-command one - activity pause had no `--reason` flag despite the server-side `PauseActivityRequest` accepting one - `--activity-type` showed `activity-id` as its value placeholder in pause, unpause, and reset help output - `--reset-heartbeats` on unpause and reset incorrectly claimed it only works with `--reset-attempts` - activity complete and activity fail lacked the `-a` shorthand for `--activity-id` that the other activity subcommands already had ## Why? These were found during an internal bug bash as either bugs or inconsistencies. ## Checklist 1. Closes NA 2. How was this tested: Manually 3. Any docs updates needed? No
1 parent 132b6dd commit 2cb6982

3 files changed

Lines changed: 27 additions & 15 deletions

File tree

internal/temporalcli/commands.activity.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ func (c *TemporalActivityPauseCommand) run(cctx *CommandContext, args []string)
247247
WorkflowId: c.WorkflowId,
248248
RunId: c.RunId,
249249
},
250-
Identity: c.Parent.Identity,
250+
Identity: c.Identity,
251+
Reason: c.Reason,
252+
}
253+
if request.Identity == "" {
254+
request.Identity = c.Parent.Identity
251255
}
252256

253257
if c.ActivityId != "" && c.ActivityType != "" {

internal/temporalcli/commands.gen.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func NewTemporalActivityCompleteCommand(cctx *CommandContext, parent *TemporalAc
447447
s.Command.Long = "Complete an Activity, marking it as successfully finished. Specify the\nActivity ID and include a JSON result for the returned value:\n\n```\ntemporal activity complete \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --result '{\"YourResultKey\": \"YourResultVal\"}'\n```"
448448
}
449449
s.Command.Args = cobra.NoArgs
450-
s.Command.Flags().StringVar(&s.ActivityId, "activity-id", "", "Activity ID to complete. Required.")
450+
s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "Activity ID to complete. Required.")
451451
_ = cobra.MarkFlagRequired(s.Command.Flags(), "activity-id")
452452
s.Command.Flags().StringVar(&s.Result, "result", "", "Result `JSON` to return. Required.")
453453
_ = cobra.MarkFlagRequired(s.Command.Flags(), "result")
@@ -481,7 +481,7 @@ func NewTemporalActivityFailCommand(cctx *CommandContext, parent *TemporalActivi
481481
s.Command.Long = "Fail an Activity, marking it as having encountered an error. Specify the\nActivity and Workflow IDs:\n\n```\ntemporal activity fail \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n```"
482482
}
483483
s.Command.Args = cobra.NoArgs
484-
s.Command.Flags().StringVar(&s.ActivityId, "activity-id", "", "Activity ID to fail. Required.")
484+
s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "Activity ID to fail. Required.")
485485
_ = cobra.MarkFlagRequired(s.Command.Flags(), "activity-id")
486486
s.Command.Flags().StringVar(&s.Detail, "detail", "", "Reason for failing the Activity (JSON).")
487487
s.Command.Flags().StringVar(&s.Reason, "reason", "", "Reason for failing the Activity.")
@@ -501,6 +501,7 @@ type TemporalActivityPauseCommand struct {
501501
ActivityId string
502502
ActivityType string
503503
Identity string
504+
Reason string
504505
}
505506

506507
func NewTemporalActivityPauseCommand(cctx *CommandContext, parent *TemporalActivityCommand) *TemporalActivityPauseCommand {
@@ -516,8 +517,9 @@ func NewTemporalActivityPauseCommand(cctx *CommandContext, parent *TemporalActiv
516517
}
517518
s.Command.Args = cobra.NoArgs
518519
s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to pause. Either `activity-id` or `activity-type` must be provided, but not both.")
519-
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "All activities of the Activity Type will be paused. Either `activity-id` or `activity-type` must be provided, but not both. Note: Pausing Activity by Type is an experimental feature and may change in the future.")
520+
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of the given `activity-type` will be paused. Mutually exclusive with `activity-id`. Note: Pausing Activity by Type is an experimental feature and may change in the future.")
520521
s.Command.Flags().StringVar(&s.Identity, "identity", "", "The identity of the user or client submitting this request.")
522+
s.Command.Flags().StringVar(&s.Reason, "reason", "", "Reason for pausing the Activity.")
521523
s.WorkflowReferenceOptions.BuildFlags(s.Command.Flags())
522524
s.Command.Run = func(c *cobra.Command, args []string) {
523525
if err := s.run(cctx, args); err != nil {
@@ -554,10 +556,10 @@ func NewTemporalActivityResetCommand(cctx *CommandContext, parent *TemporalActiv
554556
}
555557
s.Command.Args = cobra.NoArgs
556558
s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to reset. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified.")
557-
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of this Type will be reset. Mutually exclusive with `--match-all` and `activity-id`. Note: Resetting Activity by Type is an experimental feature and may change in the future.")
559+
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of the given `activity-type` will be reset. Mutually exclusive with --match-all and `activity-id`. Note: Resetting Activity by Type is an experimental feature and may change in the future.")
558560
s.Command.Flags().BoolVar(&s.KeepPaused, "keep-paused", false, "If the activity was paused, it will stay paused.")
559561
s.Command.Flags().BoolVar(&s.ResetAttempts, "reset-attempts", false, "Reset the activity attempts.")
560-
s.Command.Flags().BoolVar(&s.ResetHeartbeats, "reset-heartbeats", false, "Reset the Activity's heartbeats. Only works with --reset-attempts.")
562+
s.Command.Flags().BoolVar(&s.ResetHeartbeats, "reset-heartbeats", false, "Reset the Activity's heartbeats.")
561563
s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every activity should be reset. Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`. Note: This is an experimental feature and may change in the future.")
562564
s.Jitter = 0
563565
s.Command.Flags().Var(&s.Jitter, "jitter", "The activity will reset at random a time within the specified duration. Can only be used with --query.")
@@ -596,9 +598,9 @@ func NewTemporalActivityUnpauseCommand(cctx *CommandContext, parent *TemporalAct
596598
}
597599
s.Command.Args = cobra.NoArgs
598600
s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to unpause. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified.")
599-
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of this Type will unpause. Can only be used without --match-all. Either `activity-id` or `activity-type` must be provided, but not both. Note: Unpausing Activity by Type is an experimental feature and may change in the future.")
601+
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of the given `activity-type` will be unpaused. Mutually exclusive with `activity-id` and --match-all. Note: Unpausing Activity by Type is an experimental feature and may change in the future.")
600602
s.Command.Flags().BoolVar(&s.ResetAttempts, "reset-attempts", false, "Reset the activity attempts.")
601-
s.Command.Flags().BoolVar(&s.ResetHeartbeats, "reset-heartbeats", false, "Reset the Activity's heartbeats. Only works with --reset-attempts.")
603+
s.Command.Flags().BoolVar(&s.ResetHeartbeats, "reset-heartbeats", false, "Reset the Activity's heartbeats.")
602604
s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every paused activity should be unpaused. This flag is ignored if activity-type is provided. Note: This is an experimental feature and may change in the future.")
603605
s.Jitter = 0
604606
s.Command.Flags().Var(&s.Jitter, "jitter", "The activity will start at random a time within the specified duration. Can only be used with --query.")

internal/temporalcli/commands.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ commands:
198198
```
199199
options:
200200
- name: activity-id
201+
short: a
201202
type: string
202203
description: Activity ID to complete.
203204
required: true
@@ -221,6 +222,7 @@ commands:
221222
```
222223
options:
223224
- name: activity-id
225+
short: a
224226
type: string
225227
description: Activity ID to fail.
226228
required: true
@@ -376,11 +378,15 @@ commands:
376378
- name: activity-type
377379
type: string
378380
description: |
379-
All activities of the Activity Type will be paused. Either `activity-id` or `activity-type` must be provided, but not both.
381+
Activities of the given `activity-type` will be paused. Mutually
382+
exclusive with `activity-id`.
380383
Note: Pausing Activity by Type is an experimental feature and may change in the future.
381384
- name: identity
382385
type: string
383386
description: The identity of the user or client submitting this request.
387+
- name: reason
388+
type: string
389+
description: Reason for pausing the Activity.
384390
option-sets:
385391
- workflow-reference
386392

@@ -430,15 +436,15 @@ commands:
430436
- name: activity-type
431437
type: string
432438
description: |
433-
Activities of this Type will unpause. Can only be used without --match-all. Either `activity-id` or `activity-type` must be provided, but not both.
439+
Activities of the given `activity-type` will be unpaused. Mutually
440+
exclusive with `activity-id` and --match-all.
434441
Note: Unpausing Activity by Type is an experimental feature and may change in the future.
435442
- name: reset-attempts
436443
type: bool
437444
description: Reset the activity attempts.
438445
- name: reset-heartbeats
439446
type: bool
440-
description: |
441-
Reset the Activity's heartbeats. Only works with --reset-attempts.
447+
description: Reset the Activity's heartbeats.
442448
- name: match-all
443449
type: bool
444450
description: |
@@ -511,7 +517,8 @@ commands:
511517
- name: activity-type
512518
type: string
513519
description: |
514-
Activities of this Type will be reset. Mutually exclusive with `--match-all` and `activity-id`.
520+
Activities of the given `activity-type` will be reset. Mutually
521+
exclusive with --match-all and `activity-id`.
515522
Note: Resetting Activity by Type is an experimental feature and may change in the future.
516523
- name: keep-paused
517524
type: bool
@@ -521,8 +528,7 @@ commands:
521528
description: Reset the activity attempts.
522529
- name: reset-heartbeats
523530
type: bool
524-
description: |
525-
Reset the Activity's heartbeats. Only works with --reset-attempts.
531+
description: Reset the Activity's heartbeats.
526532
- name: match-all
527533
type: bool
528534
description: |

0 commit comments

Comments
 (0)