Skip to content

send_task_failure async

send_task_failure(
    task_token: TaskToken,
    *,
    config_overrides: Optional[AsyncSFNClientConfig] = None,
    error: Optional[SensitiveError] = None,
    cause: Optional[SensitiveCause] = None,
) -> SendTaskFailureOutput

Used by activity workers, Task states using the callback pattern, and optionally Task states using the job run pattern to report that the task identified by the taskToken failed.

For an execution with encryption enabled, Step Functions will encrypt the error and cause fields using the KMS key for the execution role.

A caller can mark a task as fail without using any KMS permissions in the execution role if the caller provides a null value for both error and cause fields because no data needs to be encrypted.

Parameters:

Raises:

  • InvalidToken –

    The provided token is not valid.

  • KmsAccessDeniedException –

    Either your KMS key policy or API caller does not have the required permissions.

  • KmsInvalidStateException –

    The KMS key is not in valid state, for example: Disabled or Deleted.

  • KmsThrottlingException –

    Received when KMS returns ThrottlingException for a KMS call that Step Functions makes on behalf of the caller.

  • TaskDoesNotExist –

    The activity does not exist.

  • TaskTimedOut –

    The task token has either expired or the task associated with the token has already been closed.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sfn/_services/async_sfn.py
async def send_task_failure(
    self,
    task_token: "capo_sfn.types.task_token.TaskToken",
    *,
    config_overrides: Optional[AsyncSFNClientConfig] = None,
    error: Optional["capo_sfn.types.sensitive_error.SensitiveError"] = None,
    cause: Optional["capo_sfn.types.sensitive_cause.SensitiveCause"] = None,
) -> "capo_sfn.types.send_task_failure_output.SendTaskFailureOutput":
    """<p>Used by activity workers, Task states using the <a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-wait-token">callback</a> pattern, and optionally Task states using the <a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-sync">job run</a> pattern to report that the task identified by the <code>taskToken</code> failed.</p> <p>For an execution with encryption enabled, Step Functions will encrypt the error and cause fields using the KMS key for the execution role.</p> <p>A caller can mark a task as fail without using any KMS permissions in the execution role if the caller provides a null value for both <code>error</code> and <code>cause</code> fields because no data needs to be encrypted.</p>

    Args:
        task_token: <p>The token that represents this task. Task tokens are generated by Step Functions when tasks are assigned to a worker, or in the <a href="https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html">context object</a> when a workflow enters a task state. See <a>GetActivityTaskOutput$taskToken</a>.</p>
        error: <p>The error code of the failure.</p>
        cause: <p>A more detailed explanation of the cause of the failure.</p>

    Raises:
        capo_sfn.errors.invalid_token.InvalidToken: <p>The provided token is not valid.</p>
        capo_sfn.errors.kms_access_denied_exception.KmsAccessDeniedException: <p>Either your KMS key policy or API caller does not have the required permissions.</p>
        capo_sfn.errors.kms_invalid_state_exception.KmsInvalidStateException: <p>The KMS key is not in valid state, for example: Disabled or Deleted.</p>
        capo_sfn.errors.kms_throttling_exception.KmsThrottlingException: <p>Received when KMS returns <code>ThrottlingException</code> for a KMS call that Step Functions makes on behalf of the caller.</p>
        capo_sfn.errors.task_does_not_exist.TaskDoesNotExist: <p>The activity does not exist.</p>
        capo_sfn.errors.task_timed_out.TaskTimedOut: <p>The task token has either expired or the task associated with the token has already been closed.</p>
        capo_sfn.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_sfn.types.send_task_failure_input.SendTaskFailureInput]",
    ) -> AsyncOperationResponse[
        "capo_sfn.types.send_task_failure_output.SendTaskFailureOutput"
    ]:
        import capo_sfn._operations.aws_step_functions.send_task_failure

        (
            output,
            http_response,
        ) = await capo_sfn._operations.aws_step_functions.send_task_failure.async_send_task_failure(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_sfn.types.send_task_failure_input.SendTaskFailureInput",
    ) -> dict[str, Any]:
        import capo_sfn.types.send_task_failure_input

        return capo_sfn.types.send_task_failure_input.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("SendTaskFailure", redact_input=_redact_input),
    )
    input_: capo_sfn.types.send_task_failure_input.SendTaskFailureInput = {
        "task_token": task_token
    }
    if error is not None:
        input_["error"] = error
    if cause is not None:
        input_["cause"] = cause

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output