Stop Job step

End a Glue job run early, as a success or an error.

The Stop Job step ends the run there and then, either as a success or as an error. Use it to bail out early when there's nothing to do, or to fail a run on purpose with a clear message.

Set it up

In the appdata fieldWhat it does
StatusstatusSuccess (the default) or Error.
MessagemessageWhy the job stopped. Liquid works, so Order {{ order_id }} not found is fine.

How it behaves

  • Success ends the run quietly. Nothing after the step runs, and nothing is logged as a Glue error.
  • Error ends the run and logs a Glue error with your message, so it shows in Glue › Errors. The job is not retried: you stopped it on purpose, so a retry wouldn't help.
  • Any Lock the run holds is released when it stops.
  • Stop Job usually sits inside an If Condition branch.

Example 1: Stop as a success when there's nothing to do

Trigger: System Hook, Create Sale.

  1. Script: Read the sale

    var sale = JSON.parse($.default);
    $.sale = sale;
    $.has_lines = (sale.lines || []).length > 0;
  2. If Condition: If the sale has lines, Condition $.has_lines === true.

    • THEN: Script: Keep going (any steps that should only run for sales with lines).
    • ELSE: Stop Job: Stop as a success, Status Success, Message No lines on sale {{ sale.id }}.
  3. API Request: Post the sale, at the top level. It only runs when the job didn't stop.

Example 2: Fail clearly when a record is missing

Trigger: Webhook.

  1. Script: Read the payload, which sets $.order_id.
  2. REST Request: Look up the order, Fail on bad response code off, Response variable lookup_res.
  3. Script: Read the lookup: $.found = $.lookup_res.status === 200;
  4. If Condition: If the order was found, Condition $.found === true.
    • THEN: Script: Keep the order, then the steps that use it.
    • ELSE: Stop Job: Stop with an error, Status Error, Message Order {{ order_id }} not found.

The error and your message appear in Glue › Errors, so someone can follow up.

Tips

  • Use Error for things a person should look at, and Success for "nothing to do".
  • Stop instead of nesting deeply. An early Stop Job in an ELSE branch can save wrapping the rest of the job in a THEN.

← All Glue step guides


Did this page help you?