feat(st2client): allow delete commands to accept multiple ids by Yusuf-Hussien · Pull Request #6411 · StackStorm/st2 · GitHub
Skip to content

feat(st2client): allow delete commands to accept multiple ids - #6411

Open
Yusuf-Hussien wants to merge 1 commit into
StackStorm:masterfrom
Yusuf-Hussien:feature/4729-multi-resource-delete
Open

Yusuf-Hussien wants to merge 1 commit into
StackStorm:masterfrom
Yusuf-Hussien:feature/4729-multi-resource-delete

Conversation

@Yusuf-Hussien

Copy link
Copy Markdown

What and why

Closes #4729.

st2 <resource> delete only accepted a single positional id, so bulk removal (e.g. after installing a testing pack with many action aliases) required one invocation per resource:

st2 action-alias delete pack.alias1 pack.alias2   # failed before this change

Changes

  • ResourceDeleteCommand now takes nargs="+" and loops over the provided ids, mirroring how st2 <resource> get already handles multiple ids.
  • A success message is printed for every deleted resource (same wording as before).
  • Ids which are not found are reported with the usual <Resource> "<id>" is not found. message; the remaining ids are still attempted and the command exits with a non-zero return code afterwards, so partial bulk deletes are visible to scripts.
  • Single id behavior is unchanged: a missing resource still fails with the same message and non-zero exit code.
  • ActionDeleteCommand and KeyValuePairDeleteCommand were refactored to override the new delete_resource() hook instead of run(), so they automatically support multiple ids too. As a side effect, st2 action delete <missing-id> now exits non-zero like the other delete commands (it previously exited 0).
  • Added a CHANGELOG entry.

Testing

  • New unit tests in st2client/tests/unit/test_commands.py:
    • multi-id delete happy path (all ids deleted),
    • partial failure (continues past a missing id, one DELETE issued, exits non-zero),
    • all ids missing (reported + exits non-zero),
    • shell-level test covering every delete-capable resource for both multi-id and single-id not-found cases.
  • Ran pytest st2client/tests/unit locally (Python 3.11): 241 passed; the only failures are 4 pre-existing environment-related failures which also fail on unmodified master.
  • black --check and flake8 (repo config) are clean on the changed files.

Drafted with AI assistance; reviewed and tested locally.

All st2 <resource> delete commands now accept multiple positional ids, e.g. st2 action-alias delete id1 id2 id3. Existing single id behavior is unchanged; when deleting multiple ids, resources which are not found are reported and the command exits with a non-zero return code after attempting to delete the remaining resources.

Fixes StackStorm#4729

Signed-off-by: Yusuf Hussien <yhussien01@gmail.com>
@pull-request-size pull-request-size Bot added the size/L PR that changes 100-499 lines. Requires some effort to review. label Oct 7, 2026
@CLAassistant

CLAassistant commented Oct 7, 2026 •

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L PR that changes 100-499 lines. Requires some effort to review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'st2 <thing> delete' should accept multiple positional args for removal

2 participants