Skip to content

validate_state_machine_definition

validate_state_machine_definition(
    definition: Definition,
    *,
    config_overrides: Optional[SFNClientConfig] = None,
    type: Optional[StateMachineType] = None,
    severity: Optional[ValidateStateMachineDefinitionSeverity] = None,
    max_results: Optional[ValidateStateMachineDefinitionMaxResult] = None,
) -> ValidateStateMachineDefinitionOutput

Validates the syntax of a state machine definition specified in Amazon States Language (ASL), a JSON-based, structured language.

You can validate that a state machine definition is correct without creating a state machine resource.

Suggested uses for ValidateStateMachineDefinition:

  • Integrate automated checks into your code review or Continuous Integration (CI) process to check state machine definitions before starting deployments.

  • Run validation from a Git pre-commit hook to verify the definition before committing to your source repository.

Validation will look for problems in your state machine definition and return a result and a list of diagnostic elements.

The result value will be OK when your workflow definition can be successfully created or updated. Note the result can be OK even when diagnostic warnings are present in the response. The result value will be FAIL when the workflow definition contains errors that would prevent you from creating or updating your state machine.

The list of ValidateStateMachineDefinitionDiagnostic data elements can contain zero or more WARNING and/or ERROR elements.

The ValidateStateMachineDefinition API might add new diagnostics in the future, adjust diagnostic codes, or change the message wording. Your automated processes should only rely on the value of the result field value (OK, FAIL). Do not rely on the exact order, count, or wording of diagnostic messages.

Parameters:

  • definition (Definition) –

    The Amazon States Language definition of the state machine. For more information, see Amazon States Language (ASL).

  • type (Optional[StateMachineType], default: None ) –

    The target type of state machine for this definition. The default is STANDARD.

  • severity (Optional[ValidateStateMachineDefinitionSeverity], default: None ) –

    Minimum level of diagnostics to return. ERROR returns only ERROR diagnostics, whereas WARNING returns both WARNING and ERROR diagnostics. The default is ERROR.

  • max_results (Optional[ValidateStateMachineDefinitionMaxResult], default: None ) –

    The maximum number of diagnostics that are returned per call. The default and maximum value is 100. Setting the value to 0 will also use the default of 100.

    If the number of diagnostics returned in the response exceeds maxResults, the value of the truncated field in the response will be set to true.

Raises:

  • ValidationException –

    The input does not satisfy the constraints specified by an Amazon Web Services service.

  • UnknownServiceError –

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

Source code in docs_src/capo_sfn/_services/sfn.py
def validate_state_machine_definition(
    self,
    definition: "capo_sfn.types.definition.Definition",
    *,
    config_overrides: Optional[SFNClientConfig] = None,
    type: Optional["capo_sfn.types.state_machine_type.StateMachineType"] = None,
    severity: Optional[
        "capo_sfn.types.validate_state_machine_definition_severity.ValidateStateMachineDefinitionSeverity"
    ] = None,
    max_results: Optional[
        "capo_sfn.types.validate_state_machine_definition_max_result.ValidateStateMachineDefinitionMaxResult"
    ] = None,
) -> "capo_sfn.types.validate_state_machine_definition_output.ValidateStateMachineDefinitionOutput":
    """<p>Validates the syntax of a state machine definition specified in <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html">Amazon States Language</a> (ASL), a JSON-based, structured language.</p> <p>You can validate that a state machine definition is correct without creating a state machine resource.</p> <p>Suggested uses for <code>ValidateStateMachineDefinition</code>:</p> <ul> <li> <p>Integrate automated checks into your code review or Continuous Integration (CI) process to check state machine definitions before starting deployments.</p> </li> <li> <p>Run validation from a Git pre-commit hook to verify the definition before committing to your source repository.</p> </li> </ul> <p>Validation will look for problems in your state machine definition and return a <b>result</b> and a list of <b>diagnostic elements</b>.</p> <p>The <b>result</b> value will be <code>OK</code> when your workflow definition can be successfully created or updated. Note the result can be <code>OK</code> even when diagnostic warnings are present in the response. The <b>result</b> value will be <code>FAIL</code> when the workflow definition contains errors that would prevent you from creating or updating your state machine. </p> <p>The list of <a href="https://docs.aws.amazon.com/step-functions/latest/apireference/API_ValidateStateMachineDefinitionDiagnostic.html">ValidateStateMachineDefinitionDiagnostic</a> data elements can contain zero or more <b>WARNING</b> and/or <b>ERROR</b> elements.</p> <note> <p>The <b>ValidateStateMachineDefinition API</b> might add new diagnostics in the future, adjust diagnostic codes, or change the message wording. Your automated processes should only rely on the value of the <b>result</b> field value (OK, FAIL). Do <b>not</b> rely on the exact order, count, or wording of diagnostic messages.</p> </note>

    Args:
        definition: <p>The Amazon States Language definition of the state machine. For more information, see <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html">Amazon States Language</a> (ASL).</p>
        type: <p>The target type of state machine for this definition. The default is <code>STANDARD</code>.</p>
        severity: <p>Minimum level of diagnostics to return. <code>ERROR</code> returns only <code>ERROR</code> diagnostics, whereas <code>WARNING</code> returns both <code>WARNING</code> and <code>ERROR</code> diagnostics. The default is <code>ERROR</code>. </p>
        max_results: <p>The maximum number of diagnostics that are returned per call. The default and maximum value is 100. Setting the value to 0 will also use the default of 100.</p> <p>If the number of diagnostics returned in the response exceeds <code>maxResults</code>, the value of the <code>truncated</code> field in the response will be set to <code>true</code>.</p>

    Raises:
        capo_sfn.errors.validation_exception.ValidationException: <p>The input does not satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_sfn.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sfn.types.validate_state_machine_definition_input.ValidateStateMachineDefinitionInput]",
    ) -> OperationResponse[
        "capo_sfn.types.validate_state_machine_definition_output.ValidateStateMachineDefinitionOutput"
    ]:
        import capo_sfn._operations.aws_step_functions.validate_state_machine_definition

        output, http_response = (
            capo_sfn._operations.aws_step_functions.validate_state_machine_definition.validate_state_machine_definition(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

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

        return (
            capo_sfn.types.validate_state_machine_definition_input.redact_sensitive(
                input_
            )
        )

    def _redact_output(
        output: "capo_sfn.types.validate_state_machine_definition_output.ValidateStateMachineDefinitionOutput",
    ) -> dict[str, Any]:
        import capo_sfn.types.validate_state_machine_definition_output

        return capo_sfn.types.validate_state_machine_definition_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "ValidateStateMachineDefinition",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_sfn.types.validate_state_machine_definition_input.ValidateStateMachineDefinitionInput = {
        "definition": definition
    }
    if type is not None:
        input_["type"] = type
    if severity is not None:
        input_["severity"] = severity
    if max_results is not None:
        input_["max_results"] = max_results

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output