StackStorm / StackStorm/st2

The built-in "st2.action.file_written" trigger is not working.

Open
#5,665 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

SUMMARY

The "st2.action.file_written" trigger is not working when creating a new action.

STACKSTORM VERSION

3.7

OS, environment, install method
  • Window 10, WSL 2: Ubuntu 22.04
  • Docker

Steps to reproduce the problem

  • Create a new rule with "st2.action.file_written" trigger and "core.echo" for output the payload of the trigger.
  • Create a new action by st2client or st2web.

Expected Results

Execute the rule and output the payload of st2.action.file_written trigger.

Actual Results

Nothing!

Root cause:

Missing the "pack" info when dispatching this trigger:
https://github.com/StackStorm/st2/blob/v3.7/st2api/st2api/controllers/v1/actions.py#L533

def _dispatch_trigger_for_written_data_files(self, action_db, written_data_files):
        trigger = ACTION_FILE_WRITTEN_TRIGGER["name"]
        host_info = get_host_info()

        for file_path in written_data_files:
            payload = {
                "ref": action_db.ref,
                "file_path": file_path,
                "host_info": host_info,
            }
            self._trigger_dispatcher.dispatch(trigger=trigger, payload=payload)

Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

In st2api/st2api/controllers/v1/actions.py, start at _dispatch_trigger_for_written_data_files and inspect how the trigger dispatcher is called for newly created actions. Reproduce the rule with st2.action.file_written and core.echo, then verify that the trigger fires and its payload is available to the rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.