# Mender 2.2 ArtifactFailure State Script Documentation Unclear

**URL:** <https://hub.mender.io/t/mender-2-2-artifactfailure-state-script-documentation-unclear/2034>\
**Category:** General Discussions\
**Created:** [June 10, 2020, 7:30pm UTC](https://hub.mender.io/t/mender-2-2-artifactfailure-state-script-documentation-unclear/2034 "2020-06-10T19:30:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amorgan](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/amorgan/32/778_2.png) [@amorgan](https://hub.mender.io/u/amorgan)\
**Post date:** [June 10, 2020, 7:30pm UTC](https://hub.mender.io/t/mender-2-2-artifactfailure-state-script-documentation-unclear/2034/1 "2020-06-10T19:30:09Z")

</div>

Hi there,

I’m looking into handling errors better during an over the air update using Mender 2.2, and I have a question about something that’s vague on the [documentation](https://docs.mender.io/2.2/artifacts/state-scripts).

**ArtifactFailure**  
The documentation contradicts itself about where exactly in the process this state occurs. Towards the top, it says this, which is consistent with the diagrams on the page:

> **ArtifactFailure** : if any of the “Artifact” states are failing, the device enters and executes this state. This state always runs after the ArtifactRollback and ArtifactRollbackReboot states.

However, at the end of the page it shows an example of the state transitions for if an error occurred during the `ArtifactCommit` state. This example seems to contradict the above quote since the `ArtifactFailure` state happens before the `ArtifactRollback` and `ArtifactRollbackReboot` states. It shows the following order:

> - [ArtifactCommit\_Enter] ArtifactCommit
> - (error while committing)
> - [ArtifactCommit\_Error]
> - [ArtifactFailure\_Enter] ArtifactFailure [ArtifactFailure\_Leave]
> - [ArtifactRollback\_Enter] ArtifactRollback [ArtifactRollback\_Leave]
> - [ArtifactRollbackReboot\_Enter] ArtifactRollbackReboot
> - (device reboot)
> - [ArtifactRollbackReboot\_Leave]

So is the top quote correct and the `ArtifactFailure` state scripts would run after the rollback reboot in the example, or is the example correct?  
Thanks!

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [June 10, 2020, 7:52pm UTC](https://hub.mender.io/t/mender-2-2-artifactfailure-state-script-documentation-unclear/2034/2 "2020-06-10T19:52:44Z")

</div>

Hi @amorgan, welcome to Mender Hub.

I think you are referring to the sequencing specifically in [https://docs.mender.io/2.3/artifacts/state-scripts#error-while-committing-an-update](https://docs.mender.io/2.3/artifacts/state-scripts#error-while-committing-an-update) right?

@kacf can you comment? This link does seem to show that ArtifactFailure happens before Rollback in this case.

Drew

---

<div class="post-metadata">

**Author:** ![amorgan](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/amorgan/32/778_2.png) [@amorgan](https://hub.mender.io/u/amorgan)\
**Post date:** [June 10, 2020, 8:05pm UTC](https://hub.mender.io/t/mender-2-2-artifactfailure-state-script-documentation-unclear/2034/3 "2020-06-10T20:05:24Z")

</div>

Hi @drewmoseley,

Yes that is what I’m referring to, which is also present on the corresponding page for version 2.2.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 11, 2020, 8:07am UTC](https://hub.mender.io/t/mender-2-2-artifactfailure-state-script-documentation-unclear/2034/4 "2020-06-11T08:07:51Z")

</div>

You are correct, this is a mistake in the documentation. The actual behavior is “documented” [in our tests](https://github.com/mendersoftware/mender/blob/1cf2f8a7b0ef7736550315ec8ade938cef8332f2/app/state_test.go#L2310-L2322). There are in fact several mistakes in the state script order on that page; here is [a pull request](https://github.com/mendersoftware/mender-docs/pull/1008) to fix them.

---

<div class="post-metadata">

**Author:** ![amorgan](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/amorgan/32/778_2.png) [@amorgan](https://hub.mender.io/u/amorgan)\
**Post date:** [June 11, 2020, 4:23pm UTC](https://hub.mender.io/t/mender-2-2-artifactfailure-state-script-documentation-unclear/2034/5 "2020-06-11T16:23:53Z")

</div>

Great, thanks for the quick reply and fix!
