[BUG] execute reports automations as executed although Marketing Cloud did not start a run (automation never ran before)

Open
#2,792 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
devtools

Research direction

Start in lib/metadataTypes/Automation.js, especially Automation.execute(), and trace how SOAP Perform responses become executedKeyArr entries. Review the public REST automation read and the proposed run status fields, then inspect or add tests with REST fixtures for both a started run and an accepted request with no run. Done means mcdev counts only confirmed starts as executed and warns when Marketing Cloud accepts the request but no run begins.

Written by the indexing model from the issue text.

Description

bug c/automation

Describe the bug
mcdev execute -m automation:<key> reports the automation as executed, but Marketing Cloud does not start a run when the automation has never run before. Nothing shows up in the run log, and mcdev prints success.

Tested live on a test business unit with mcdev 10.3.1:

  1. Deployed a new scheduled automation (status PausedSchedule, one data extract step) with mcdev deploy -m automation:probe-exec-fresh.
  2. Ran mcdev execute -m automation:probe-exec-fresh right away, and again 2 minutes later.
    • Both times mcdev logged - executed automation: probe-exec-fresh and Executed 1 of 1 items.
    • Automation Studio still showed "This automation has not run" (checked after more than a minute, page reloaded). REST GET /automation/v1/automations/{id} still returned status: PausedSchedule and no lastRunTime.
  3. Started the automation once in Automation Studio (Run Once > Select All Activities > Run > Run Now). It ran.
  4. Ran mcdev execute -m automation:probe-exec-fresh again: this time a run started at once (status Running, then Complete).

The same happened with a four-step automation (data extract, two file transfers, import): the first mcdev execute 13 seconds after the deploy did nothing; after one Run Once in the UI, mcdev execute started a run immediately.

What mcdev sends and gets back

Automation.execute() sends the documented SOAP call (Perform on the Automation object):

<PerformRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
  <Action>start</Action>
  <Definitions><Definition xsi:type="Automation"><ObjectID>{automation id}</ObjectID></Definition></Definitions>
</PerformRequestMsg>

Response for the never-run automation (identical to a working call):

<PerformResponseMsg>
  <Results><Result><StatusCode>OK</StatusCode></Result></Results>
  <OverallStatus>OK</OverallStatus><OverallStatusMessage />
</PerformResponseMsg>

mcdev counts every item with OverallStatus === 'OK' as executed, so the ignored start is reported as a success.

For comparison, the Automation Studio UI's Run Once sends POST /automation/v1/automations/{id}/actions/start with the selected step activities ({"steps":[{"activities":[{"id":"…","IsIncludedInRun":true}]}]}) and gets 201 "Automation Started Successfully". That endpoint is not in the public API documentation, so this ticket does not propose switching to it.

Related, already known: an automation created via REST without a starting source makes the same SOAP Perform start fail with Exception occurred during [PerformOptionStart]; mcdev reports that one correctly as not executed.

Expected behavior

  • mcdev only reports an automation as executed when a run actually started.
  • If Marketing Cloud accepted the request but no run started, mcdev logs a clear warning, for example: "Marketing Cloud accepted the start request for automation 'x' but did not start a run. Automations that have never run must be started once in Automation Studio (Run Once) before mcdev execute can start them."

Proposed fix
In Automation.execute() (lib/metadataTypes/Automation.js), after a Perform response with OverallStatus OK:

  1. Read the automation via GET /automation/v1/automations/{id} (public API) and check whether a run started: status is Running (statusId 3), or lastRunInstanceId / lastRunTime changed compared with a read taken before the Perform call. Retry a few times over a few seconds, because the run can take a moment to appear.
  2. If no run started, log the warning above and leave the key out of the returned executedKeyArr, so Executed x of y items is correct.
  3. Optional: if the pre-Perform read already shows no lastRunTime, warn up front that the automation has never run.

Add tests for both cases (run started / no run started) with the matching REST fixtures.

Version
10.3.1

Dominant language
JavaScript
Stars
166
Forks
50
Avg merge
11h 4m
Merged PRs (30d)
36

Getting set up

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.

More from Accenture/sfmc-devtools

All issues in Accenture/sfmc-devtools

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.