<@U04S8PLJWMT> I use a stream that uses a parent s...
# ask-ai
y
@kapa.ai I use a stream that uses a parent stream partition router. The URL of the "child" stream is
https://graph.facebook.com/v22.0/{{stream_partition.page_id}}/insights
I want to be able to print the
{{ stream_partition.page_id }}
in an error message. For context, I use Airbyte Cloud. What solution do you suggest ?
k
New message text here
y
@kapa.ai What is you recommendation between this and using headers ?
k
A message from kapa.ai
New message text here
y
@kapa.ai So I can write the error message : An error was detected and ignored for page ID : {{stream_partition.page_id}}. HEADERS : {{ headers }} ; RESPONSE : {{ response }} Without any issue ?
k
A message from kapa.ai
Mostly yes—but with two caveats: - headers and response are valid interpolation variables in the Connector Builder and can be used in strings/templates. [[YAML reference](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/reference#variables); [String interpolation](https://docs.airbyte.com/platform/connector-development/config-based/advanced-topics/string-interpolation)]. - stream_partition.page_id is the right way to reference the current parent slice value in Builder; using it in transformations and custom parameters is documented. [[Advanced configuration](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#advanced-configuration); [Custom parameter injection](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/partitioning#custom-parameter-injection)]. Caveats/limitations: - There’s an open bug where stream_partition["field"] inside transformations can resolve inconsistently; prefer dot notation stream_partition.page_id. [[Bug 59117](https://github.com/airbytehq/airbyte/issues/59117)]. - The docs do not explicitly state that you can template arbitrary “error message” text in the Response filter UI, but you can evaluate predicates against response/headers and act (ignore/retry/fail). If your goal is to log a custom message, the knowledge sources don’t confirm a UI field that emits a custom, templated message. [[Response filter](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/error-handling#response-filter)]. If you need the message persisted, add a field to each record with: - error_context.message: "An error was detected and ignored for page ID: {{ stream_partition.page_id }}" - error_context.headers: "{{ headers }}" - error_context.response: "{{ response }}" This guarantees the context appears in your destination and logs associated with records. [[Advanced configuration](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#advanced-configuration); [YAML reference](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/reference#variables)].
y
@kapa.ai i get this error message : ValueError: Jinja macro has undeclared variables: {'stream_partition'}.
k
A message from kapa.ai
That error means stream_partition isn’t available in the context where your Jinja is evaluated. In Builder, stream_partition only exists during partitioned requests/slices created by a partition router (e.g., Parent/Substream or List). You can reference it like {{ stream_partition.page_id }} in places tied to the request/record for that slice (URL path, request params/headers/body via custom injection, or transformations). [[Interpolation vars](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/reference#/variables/stream_partition); [Partition router types](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#partition-router-types)]. Common causes and fixes: - No partition router configured: Add a Parent/Substream (or List) partition router and set the Partition Field/Identifier (e.g., page_id). [[Partition router types](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#partition-router-types)]. - Wrong identifier: Use the exact identifier you configured, e.g., {{ stream_partition.page_id }} (dot notation is recommended over bracket syntax due to a known bug). [[Parent stream](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/partitioning#parent-stream); [Bug 59117](https://github.com/airbytehq/airbyte/issues/59117)]. - Referencing outside supported places: If you try to use stream_partition in a context that’s evaluated before slicing (or in a stream without partitions), it will be undeclared. Move the expression into: - URL path or request options (query/header/body) via custom parameter injection, or - A record transformation “Add field”. [[Custom parameter injection](https://docs.airbyte.com/platform/1.7/connector-development/connector-builder-ui/partitioning#custom-parameter-injection); [Adding to record](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/partitioning#adding-the-partition-value-to-the-record)]. If you still see the error: - Verify the child stream’s partition router resolves page_id (e.g., Substream with Parent Key id → Partition Field page_id, then path /v22.0/{{ stream_partition.page_id }}/insights). [[Partition router types](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#partition-router-types)]. - As a quick check, log the whole partition with {{ stream_partition }} in a temporary transformation to confirm it’s present; then switch to {{ stream_partition.page_id }}. [[Interpolation vars](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/reference#/variables/stream_partition)].
y
@kapa.ai This is what I did :
k
Sorry @Yandi Andriamasy, it looks like your question contains files, which I cannot process. Please reformulate your question without including any files.
y
@kapa.ai I effectively have a Parent Stream config with Current parrent key value identifier : page_id In error handler : i added a default error handler with error message {{ stream_partition.page_id }}
k
A message from kapa.ai
Thanks for the details. The error happens because stream_partition isn’t guaranteed to be available in every interpolation context of the Default Error Handler. The docs confirm stream_partition is available for partitioned requests (URL/path, request params/headers/body via custom injection, and transformations), but they don’t explicitly state it’s available inside the error handler’s custom message. [[stream_partition var](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/reference#/variables/stream_partition); [Partition router types](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#partition-router-types); [HttpRequester fields](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/reference#/definitions/HttpRequester)]. Pragmatic workaround: - Add the page_id to each record via a transformation (path e.g., error_context.page_id, value {{ stream_partition.page_id }}). This is documented and reliably evaluated in the record/stream context. [[Adding the partition value](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/partitioning#adding-the-partition-value-to-the-record)]. - If you need it for request-level diagnostics, inject it into a header or query param using custom parameter injection (e.g., X-Partition: {{ stream_partition.page_id }}), then reference that header/param in your error handling logic. [[Custom parameter injection](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/partitioning#custom-parameter-injection)]. Notes: - Use dot notation {{ stream_partition.page_id }} (there’s a known bug with bracket notation in some contexts). [[Bug 59117](https://github.com/airbytehq/airbyte/issues/59117)]. - If you still see “undeclared variables,” it likely means the error handler is evaluated before the slice context is attached. In that case, prefer the transformation approach to persist page_id with records and surface it in logs/destination. [[Adding the partition value](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/partitioning#adding-the-partition-value-to-the-record)].
y
@kapa.ai I added
Source-page-idx-debug
= {{ stream_partition.page_id }} in the request header Then added : HEADERS : {{ headers }} in the error message of the error handler. My newly added header does not show in the error logs
k
A message from kapa.ai
Short answer: that’s expected. The docs don’t state that the Default Error Handler’s message template will include or render the full, mutated request headers, and they don’t guarantee that custom-injected headers are exposed back into the error template context. The variables documented for request construction (including stream_partition) are supported in URL/params/headers/body and transformations, but availability inside the error handler message isn’t specified. [[HttpRequester](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/reference#/definitions/HttpRequester); [Error handling](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/error-handling)]. What you can do instead: - Persist the partition value in records via a transformation (e.g., error_context.page_id = {{ stream_partition.page_id }}). This reliably surfaces it for debugging. [[Advanced configuration](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#advanced-configuration)]. - If you need request-level context in errors, prefer referencing response attributes the error handler does expose (status code/body via response filters) and avoid relying on custom headers appearing in the message. The docs only describe configuring retries/filters/backoff, not echoing request headers. [[Error handling](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/error-handling)]. - For complex injection or path-based identifiers, disable automatic injection and use custom parameter injection to build the request; still, plan to log the identifier via a transformation rather than expecting it in the error message. [[Custom parameter injection](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/partitioning#custom-parameter-injection)]. Given current limitations and the absence of documented support for logging custom headers in error messages, use transformations to carry the page_id (and any needed context) into records/logs. If deeper HTTP logging is needed, note there are open requests to enhance connector logging. [[log http calls](https://github.com/airbytehq/airbyte/issues/52077); [debugging logging issue](https://github.com/airbytehq/airbyte/issues/64507)].