Skip to content

action.result

The gateway’s own event: an action (an ordered group of commands, its steps, for one device) finished. The gateway emits it once per action, with the change that finished it (the change is never made without it): the answer to its last step (ok), an answer that failed a step or a step going unanswered (failed: the steps not yet handed out are skipped and never go), or a cancel (cancelled) or expiry (timed_out) that took back steps not yet handed out. An action that stopped at a gate says which (gate_step) and why (reason); a gate that did not pass also holds the device (device.held). Each step still has its own command.result; a step handed out before the action ended reports that way after it. The envelope’s endpoint and device are the device’s, and package is the package that built the action.

Schema id: urn:houradvantage:events:3:action.result

Fields

FieldTypeRequiredDescription
action_idintegeryesThe action’s id, as the actions API gives it.
actionstringyesWhat was asked for: a standard action (upsert_user, …), a package action, or one of the package’s commands.
outcome"ok" \"failed" \"cancelled" \
stepsarray of objectyesEvery step, in order.
steps[].stepintegeryesThe step’s place in the action, counted from 1 (as reason counts steps). at least 1
steps[].command_idintegeryesThe step’s command id, as its command.result gives it.
steps[].actionstringyesThe command’s name, as the package names it.
steps[].status"queued" \"offered" \"succeeded" \
steps[].codeintegerThe device’s result code. Absent until the device answered.
steps[].resultstring or nullfailed_step only: what the device answered, as the command keeps it; for an answer the package marks sensitive, only its size (""). null when the step went unanswered.
failed_stepobjectThe step that failed the action, with the device’s answer (result). Present only when outcome is failed.
failed_step.stepintegeryesThe step’s place in the action, counted from 1 (as reason counts steps). at least 1
failed_step.command_idintegeryesThe step’s command id, as its command.result gives it.
failed_step.actionstringyesThe command’s name, as the package names it.
failed_step.status"queued" \"offered" \"succeeded" \
failed_step.codeintegerThe device’s result code. Absent until the device answered.
failed_step.resultstring or nullfailed_step only: what the device answered, as the command keeps it; for an answer the package marks sensitive, only its size (""). null when the step went unanswered.
originstringWho made the action, when it was not made through the API: “job:” for a job, “sync::…” for a sync group, “biometrics:” for the deletes of a person refused biometrics. Absent for an action made through the API.
gate_stepintegerThe gate the action stopped at, counted from 1: the gate did not pass (and held the device, see device.held), or the action was cancelled or timed out while that gate was out on the device. Absent when it did not stop at a gate. at least 1
reasonstringWhy it stopped, whenever outcome is not ok: the step it stopped at (counted from 1) and what became of it (“step 2 (add_fingerprint) failed: the device answered -5”, “step 3 (await_restart) still not done after 4 tries when the action expired”), what the gate’s device answered (“gate step 2 (query_user) of action 7 (upsert_user) did not pass: …”), or, for an action dropped when its device’s hold was released, “dropped when the device’s hold was released: ”. Absent when outcome is ok.

Examples

{
"action_id": 7,
"action": "upsert_user",
"outcome": "failed",
"steps": [
{
"step": 1,
"command_id": 41,
"action": "add_user",
"status": "succeeded",
"code": 0
},
{
"step": 2,
"command_id": 42,
"action": "add_fingerprint",
"status": "failed",
"code": -5
},
{
"step": 3,
"command_id": 43,
"action": "set_user_photo",
"status": "skipped"
}
],
"failed_step": {
"step": 2,
"command_id": 42,
"action": "add_fingerprint",
"status": "failed",
"code": -5,
"result": ""
},
"reason": "step 2 (add_fingerprint) failed: the device answered -5"
}
{
"action_id": 8,
"action": "set_settings",
"outcome": "ok",
"steps": [
{
"step": 1,
"command_id": 44,
"action": "set_option",
"status": "succeeded",
"code": 0
}
],
"origin": "job:3"
}

JSON Schema

action.result.json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "urn:houradvantage:events:3:action.result",
"title": "action.result: data",
"description": "The gateway's own event: an action (an ordered group of commands, its steps, for one device) finished. The gateway emits it once per action, with the change that finished it (the change is never made without it): the answer to its last step (ok), an answer that failed a step or a step going unanswered (failed: the steps not yet handed out are skipped and never go), or a cancel (cancelled) or expiry (timed_out) that took back steps not yet handed out. An action that stopped at a gate says which (gate_step) and why (reason); a gate that did not pass also holds the device (device.held). Each step still has its own command.result; a step handed out before the action ended reports that way after it. The envelope's endpoint and device are the device's, and package is the package that built the action.",
"type": "object",
"$defs": {
"step": {
"description": "One step of the action: one command.",
"type": "object",
"properties": {
"step": {
"type": "integer",
"minimum": 1,
"description": "The step's place in the action, counted from 1 (as reason counts steps)."
},
"command_id": {
"type": "integer",
"description": "The step's command id, as its command.result gives it."
},
"action": {
"type": "string",
"description": "The command's name, as the package names it."
},
"status": {
"enum": [
"queued",
"offered",
"succeeded",
"failed",
"unanswered",
"cancelled",
"skipped",
"parked"
],
"description": "Where the step stands when the action finishes. succeeded, failed: the device answered. unanswered: offered and lost (the device answered one offered after it, or restarted, or an app gave up on it); never by how long it took. offered: written into a reply to the device before the action ended and not answered yet; it still reports with a command.result. cancelled: taken back by a cancel or the action's expiry before it went out. skipped: not handed out when an earlier step failed. queued, parked: waiting to go (parked: behind a gate, or until a retry is due)."
},
"code": {
"type": "integer",
"description": "The device's result code. Absent until the device answered."
},
"result": {
"type": [
"string",
"null"
],
"description": "failed_step only: what the device answered, as the command keeps it; for an answer the package marks sensitive, only its size (\"<redacted N bytes>\"). null when the step went unanswered."
}
},
"required": [
"step",
"command_id",
"action",
"status"
]
}
},
"properties": {
"action_id": {
"type": "integer",
"description": "The action's id, as the actions API gives it."
},
"action": {
"type": "string",
"description": "What was asked for: a standard action (upsert_user, ...), a package action, or one of the package's commands."
},
"outcome": {
"enum": [
"ok",
"failed",
"cancelled",
"timed_out"
],
"description": "ok: every step succeeded. failed: a step failed or went unanswered (failed_step). cancelled: it was cancelled before every step went out. timed_out: it expired (expires_at passed) before every step went out."
},
"steps": {
"type": "array",
"items": {
"$ref": "#/$defs/step"
},
"description": "Every step, in order."
},
"failed_step": {
"$ref": "#/$defs/step",
"description": "The step that failed the action, with the device's answer (result). Present only when outcome is failed."
},
"origin": {
"type": "string",
"description": "Who made the action, when it was not made through the API: \"job:<id>\" for a job, \"sync:<group>:...\" for a sync group, \"biometrics:<group>\" for the deletes of a person refused biometrics. Absent for an action made through the API."
},
"gate_step": {
"type": "integer",
"minimum": 1,
"description": "The gate the action stopped at, counted from 1: the gate did not pass (and held the device, see device.held), or the action was cancelled or timed out while that gate was out on the device. Absent when it did not stop at a gate."
},
"reason": {
"type": "string",
"description": "Why it stopped, whenever outcome is not ok: the step it stopped at (counted from 1) and what became of it (\"step 2 (add_fingerprint) failed: the device answered -5\", \"step 3 (await_restart) still not done after 4 tries when the action expired\"), what the gate's device answered (\"gate step 2 (query_user) of action 7 (upsert_user) did not pass: ...\"), or, for an action dropped when its device's hold was released, \"dropped when the device's hold was released: <why>\". Absent when outcome is ok."
}
},
"required": [
"action_id",
"action",
"outcome",
"steps"
],
"examples": [
{
"action_id": 7,
"action": "upsert_user",
"outcome": "failed",
"steps": [
{
"step": 1,
"command_id": 41,
"action": "add_user",
"status": "succeeded",
"code": 0
},
{
"step": 2,
"command_id": 42,
"action": "add_fingerprint",
"status": "failed",
"code": -5
},
{
"step": 3,
"command_id": 43,
"action": "set_user_photo",
"status": "skipped"
}
],
"failed_step": {
"step": 2,
"command_id": 42,
"action": "add_fingerprint",
"status": "failed",
"code": -5,
"result": ""
},
"reason": "step 2 (add_fingerprint) failed: the device answered -5"
},
{
"action_id": 8,
"action": "set_settings",
"outcome": "ok",
"steps": [
{
"step": 1,
"command_id": 44,
"action": "set_option",
"status": "succeeded",
"code": 0
}
],
"origin": "job:3"
}
]
}