@@ -220,3 +220,48 @@ The ``$externalFunction`` stage takes a document with the following fields:
220220 - ``$addFields``
221221 - ``$replaceRoot``
222222 - ``$set``
223+
224+ Behavior
225+ ~~~~~~~~
226+
227+ The :pipeline:`$externalFunction` stage sends a request to the specified AWS Lambda
228+ resource. If the request is synchronous, the response is returned in the specified field
229+ and the pipeline continues processing. If the request is asynchronous, the
230+ pipeline continues processing without waiting for the response.
231+
232+ If a synchronous request fails, the pipeline's error handling behavior is determined
233+ by the ``onError`` field. If the request is asynchronous, the ``onError`` field
234+ only applied to AWS API errors, as opposed to AWS Lambda function errors. If the
235+ ``onError`` field is not specified, the default behavior is to send the affected
236+ document to the :term:`dead letter queue`.
237+
238+ .. list-table::
239+ :header-rows: 1
240+ :widths: 20 80
241+
242+ * - ``onError`` Value
243+ - Behavior
244+
245+ * - ``"dlq"``
246+ - The affected document is sent to the dead letter queue.
247+
248+ * - ``"ignore"``
249+ - The affected document is ignored.
250+
251+ * - ``"fail"``
252+ - The stream processor is terminated on error.
253+
254+ If the pipeline can't convert the document to proper JSON, or the configured
255+ pipeline does not create a valid bson object as a product of the final stage,
256+ the document is sent to the :term:`dead letter queue` regardless of the
257+ ``onError`` setting.
258+
259+ Errors arising from incorrect configuration of the ``$externalFunction`` operator
260+ itself, such as invalid expressions, do not trigger the ``onError`` behavior.
261+ Instead, the stream processor fails with an error message. The {+atlas-sp+} pipeline
262+ retries failed requests that may be the result of transient errors.
263+
264+ .. note::
265+
266+ The ``$externalFunction`` stage is not supported in the :ref:`Atlas Data Lake <atlas-data-lake>`.
267+
0 commit comments